Blocks & Completion Handlers

Think of blocks as c functions: (return type)functionName(input1, input2) { input1 + input2 } and you call it like this: return type = functionName (1,2) Blocks are similar: NSInteger (^mathOperation)(NSInteger x, NSInteger y) = ^NSInteger(NSInteger x,NSInteger y){ return x + y; }; You call it like this: NSInteger sum = mathOperation(1,2); Now imagine how cool it is to, instead of just passing a value to a method (like saying: here is a value, evaluate it), you can pass a whole method to it (like saying: here is something else to do!). Or better yet, here do this but only when you finish doing that! Like, load the users posts or tweets after you finish authenticating him!… Read More

Continue Reading