objective c - Filter NSArray of custom objects -


i have nsarray of contact objects, can call contacts. contact superclass, facebookgroup , individual subclasses of contact. facebookgroup has property called individuals set of individual objects.

i have nsarray of nsstring objects, can call userids.

what want create new nsarray existing contacts array match userids in userids.

so if contacts has 3 contact objects userid 1,2 , 3. , userids has nsstring object 3. want resulting array contain contact equals userid 3.

contact.h

contact : nsobject 

facebookgroup.h

facebookgroup : contact  @property (nonatomic, strong) nsset *individuals; 

individual.h

individual : contact  @property (nonatomic, strong) nsstring *userid; 

is looking for?

nspredicate *predicate = [nspredicate predicatewithformat:@"userid in %@", userids]; nsarray *filtered = [contacts filteredarrayusingpredicate:predicate]; 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -