3 ms·
For a more Objective-C-ish take on these sorts of functional idioms, have a look at Higher Order Messaging: myStrings = @[ @"hello" @"world" ]; upperCase
by mpweiher 14y ago
For a more Objective-C-ish take on these sorts of functional idioms, have a look at Higher Order Messaging:
myStrings = @[ @"hello" @"world" ];
upperCase = [[myStrings collect] upperCaseString];
myInts = @[ @1 @2 @3 ];
sum = [myInts reduce] add:@0];
[[self onMainThread] doSomething];
[[delegate ifResponds] delegateMessage];
Blocks also work, but the built-in methods tend to be a tad verbose.
- SeoxyS 14y agoWow, I just found out about Higher-Order Messaging. This is pretty awesome. Here are some links for more info: - http://cocoadev.com/wiki/HigherOrderMessaging - http://macdevcenter.com/pub/a/mac/2004/07/16/hom.html --- As an aside, I like to use my own [ATFunctionalCollectionExtensions][] for this purpose, which is a blocks-based implementation of map, reduce, inject, each, and filter. [ATFunctionalCollectionExtensions]: https://github.com/kballenegger/ATFunctionalCollectionExtensions https://github.com/kballenegger/ATFunctionalCollectionExtens...