Joined June 2014
·
Posted to
Store an Objective-C block as a property
over 1 year
ago
The code without the typedef needs to have the return type specified as void (to match the example that uses the typedef):
@property (nonatomic, copy) void (^myActionBlock)();
Personally in this case I'd consider using a typedef, unless I was making a framework or other shared code and wanted to avoid introducing too many symbols into the shared namespace.
As of Swift 2, forEach(_:) is a builtin method on SequenceType objects, so you don't need to define an extension on Array.
On the other hand, it is more usual in Swift to iterate directly on the Array: