On Jul 28, 2011, at 1:35 PM, Chris Paveglio wrote:

> I'm looking at using: - (NSArray *)filteredArrayUsingPredicate:(NSPredicate 
> *)predicate

I was going to suggest using a block to filter, but it seems that Foundation 
collections still don’t implement the standard functional operators like ‘map’ 
and ‘filter' found in lots of other languages. Which is too bad, since 
otherwise you could write it compactly as

NSArray* filtered = [paths filter: ^(NSString path){
        return [validExtensions containsObject: 
path.pathExtension.lowercaseString];
}];

There’s -indexesOfObjectsWithOptions:passingTest:, as Kyle pointed out, but 
that adds another step of generating and using an index-set.

I found the lack of -map so annoying that I wrote a category method for it in 
my current project...

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to