Unfortunately, Objective-C blocks  are often confused with threading. The root cause is probably that GCD* heavily relies on blocks.

(*)Grand Central Dispatch  is a library that makes working with threads easier.

However, the fact that GCD functions typically use blocks does not mean that blocks are bound to asynchronous execution.

Blocks do indeed simplify the work with threads – but there is no rule saying that a block can only be invoked asynchronously.

For example, you can define a block like this – no threading involved at all.

NSInteger (^add)(NSInteger, NSInteger) = ^(NSInteger left, NSInteger right
return left + right;

NSLog( @”%ld”, (long)add(40, 2) );

Blocks are simply put segments of code that can be passed to methods like you would pass values. Whether they are used with or without concurrency does not belong to their definition.
To get started with blocks visit Apple’s official documentation here:

Happy coding!

Leave A Comment