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

dispatch_after – GCD in Swift?

I use dispatch_after so often that I wrote a top-level utility function to make the syntax simpler: func delay(delay:Double, closure:()->()) { dispatch_after( dispatch_time( DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)) ), dispatch_get_main_queue(), closure) } And now you can talk like this: delay(0.4) { // do stuff } Wow, a language where you can improve the language. What could … Read more

How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:?

I think you’re looking for dispatch_after(). It requires your block to accept no parameters, but you can just let the block capture those variables from your local scope instead. int parameter1 = 12; float parameter2 = 144.1; // Delay execution of my block for 10 seconds. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ NSLog(@”parameter1: %d parameter2: … Read more

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