Does Objective-C support blocks "a la Smalltalk"?
In Smalltalk, blocks are similar to "closures" or "lambda-expressions" or "nameless functions" found in other languages.
Code blocks in Smalltalk are self-contained pieces of computation which can be activated by sending them the #value message or one of its variants. A Smalltalk block is Smalltalk's term for a closure. Blocks are instances of class BlockContext.
A closure is said to escape a function when the closure is passed as an argument to the function, but is called after the function returns. When you declare a function that takes a closure as one of its parameters, you can write @escaping before the parameter's type to indicate that the closure is allowed to escape.
Yes: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html
Out of the box, they're only supported in the version of Objective-C 2.0 that comes with XCode 3.2 or later. This means you'll need Snow Leopard if you want to use the official build tools. A potential work-around for 10.5 is described here: http://thirdcog.eu/pwcblocks/#leoiphone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With