0

I want to understand difference between dispath_queue and NSOperationQueue, when I can to write my code as:

let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
    dispatch_async(queue) { () -> Void in

        let img1 = Downloader.downloadImageWithURL(imageURLs[0])
        dispatch_async(dispatch_get_main_queue(), {
            self.imageView1.image = img1
        })

    }

and as:

queue = NSOperationQueue()

queue.addOperationWithBlock { () -> Void in
    let img4 = Downloader.downloadImageWithURL(imageURLs[3])

    NSOperationQueue.mainQueue().addOperationWithBlock({
        self.imageView4.image = img4
    })

}

So, what is the difference between these 2 blocks? If it's possible, describe it for me, please

John Doe
  • 811
  • 4
  • 14
  • 26

0 Answers0