wife married

singles swinging

singles ministry activities

friend finder.com

cuckold personals

online dating love

sex blind date

escort service female

dating service new york

chat sites adult

housewife dating

virginia beach speed dating

agultfriendfinder

spank chat

sex caht rooms

elitepartner niveauvolle singles kennenlernen

dirty dates

jam singles

asian oral

florida swinging

gay dating london

santa rosa singles

singles events montreal

local singles sex

capital district singles

native american indian dating

d s personals

phone sex local

www photo personals

medford singles

dating russian service woman

singles system requirements

christian singles dance

sex woman video

dating uk woman

www iwantu com

dating in canada

personal dating websites

affairs wife

girls to date

women seeking men in chennai

cheap chat girls

personals philadelphia

one night stand band

swapping couples

tamil affairs

friendfinder inc

swinger ro

swinging dating

meeting single men

greenock singles

adults dating minors

ireland personals

free dating sights

roseville singles

h2h personals

sex pals

online dating scammers

retreats couples

older women who like younger men

port angeles singles

sex online now

hotmatch

mix match swimwear

wife cheating

free 100 dating

redneck dating

heart singles

dieting websites

movies adults

sex mob

boys looking for sex

sex lust

married looking

have one night stand

single russian ladies

jobs for single parents

cam girls com

sexcontacts

singles in texas

www finder x com

uk dating scams

horney housewives com

sex hookups

portland asian escort

carolina christian singles

sex meet uk

couples therapy retreats

va singles

singles in south florida

swinger clubs

gay men websites

dating sites in holland

personals taiwan

thai dating uk

lesbian personal online

popular personals

single travel agency

escort service philly

student singles


Cocoa Tip: Filtering NSArray using NSPredicate

Today I’ve had a small task in one of my projects – to get subset of elements from NSArray. I’ve already started writing all this NSEnumerator’s stuff (need to support 10.4) when I remembered about NSPredicator. So, instead of iterating over an array and finding elements that satisfy some condition and adding them to some output array you just need to create predicate and filter your input array with it. Here is the sample code:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"storeState == 1"];
NSArray  *outputArray = [inputArray filteredArrayUsingPredicate:predicate];

Predicates language seems to be very powerful and simple. But I can’t tell you anything about performance, need to investigate.

UPDATE If you want to filter array with regular expressions just use a predicate like this one:

[NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexp];

Further reading: Apple Predicates Programming Guide


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

  • http://thecocoabots.com Tony Arnold

    I’ve actually found that it’s significantly faster to iterate through a set/array using fast enumeration. Predicates are great for complex situations (like parent/child groupings, etc), but they’re not as fast for very simple comparisons like you’re doing here.