Sign up FAST! Login

Objective C Blocks: Summary, Syntax & Best Practices

Stashed in: Software!, ObjectiveC, Development

To save this post, select a stash from drop-down menu or type in a new one:

From the article:

Blocks are closures for C, Objective C and C++. You may know them lambda functions.

Good usage of blocks is an excellent path to reducing typing, line count and bug count in your Cocoa programs.

Blocks should not be confused with Grand Central Dispatch (GCD): GCD is primarily a queue library, which typically uses blocks.

Blocks do have a learning curve attached to them. They also have a tremendously wonky syntax. Buyer beware: in simple situations, blocks are very readable, but excessively nested blocks can transform your source into inscrutable rivers of punctuation and indentation.

more discussion here:

Thanks Matt. Those are some beautiful blocks. 

You May Also Like: