Get notification when NSOperationQueue finishes all tasks

Use KVO to observe the operations property of your queue, then you can tell if your queue has completed by checking for [queue.operations count] == 0. Somewhere in the file you’re doing the KVO in, declare a context for KVO like this (more info): static NSString *kQueueOperationsChanged = @”kQueueOperationsChanged”; When you setup your queue, do … Read more

Wait until swift for loop with asynchronous network requests finishes executing

You can use dispatch groups to fire an asynchronous callback when all your requests finish. Here’s an example using dispatch groups to execute a callback asynchronously when multiple networking requests have all finished. override func viewDidLoad() { super.viewDidLoad() let myGroup = DispatchGroup() for i in 0 ..< 5 { myGroup.enter() Alamofire.request(“https://httpbin.org/get”, parameters: [“foo”: “bar”]).responseJSON { … Read more

NSOperation vs Grand Central Dispatch

GCD is a low-level C-based API that enables very simple use of a task-based concurrency model. NSOperation and NSOperationQueue are Objective-C classes that do a similar thing. NSOperation was introduced first, but as of 10.5 and iOS 2, NSOperationQueue and friends are internally implemented using GCD. In general, you should use the highest level of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)