title: ActivityIndicator in asynchronous - Swift
body: <p>I have heavy code - loading images asynchronously.
  <a href="https://stackoverflow.com/questions/31269716/activity-indicator-not-appearing/31270819#31270819">I am using Grand Central Dispatch</a>,
  but Activity Indicator does not working. Help me find the error, please</p>
  
  <pre><code>func loadImage() {
      if let imageUrl = NSURL(string: "http://\($url)/1.jpg") {
          let imageRequest: NSURLRequest = NSURLRequest(URL: imageUrl)
          let queue: NSOperationQueue = NSOperationQueue.mainQueue()
          NSURLConnection.sendAsynchronousRequest(imageRequest, queue: queue, completionHandler:{ (response: NSURLResponse!, data: NSData!, error: NSError!) -&gt; Void in
              if data != nil {
                  self.image = UIImage(data: data)!
                  self.productImageView.image = self.image
  
              }
          })
      }
  }
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.imageActivityIndicator.startAnimating()
      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -&gt; Void in
  
      self.loadImage()
  
      dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in
          self.imageActivityIndicator.stopAnimating()
      })
      });
  
  
  }
  </code></pre>