I am trying to filter my array with two entities within an object like I have a Person object in which I have name, address, number, email, etc. I am trying to filter my array list of objects with just name and number. How can this be achieved with using NSPredicate?
Share
Create the predicate (the following assumes that your
Personclass hasnameandnumberstring properties):Then, filter the array (this assumes you have an
NSArrayofPersonobjects):The result will be an array that contains
Personobjects whosenamecould be “Steve”, “Steven” etc, and whose number starts with555-.Edit
What you’re saying doesn’t really make sense. You can’t remove properties from a class (or rather, you shouldn’t). If you just want an array that contains only the names and numbers you’ll have to iterate through the array of
Personobjects: