I've contacts array where each contact is a dictionary.
Each contact has a key "contact_type" which is an NSNumber. Contact type basically represents whether its a Facebook, LinkedIn or Mail contact etc. I've a search array which holds only NSNumber of contact_type's.
What I want is to make a temporary array of contacts which I want to search using my search array.
I am facing trouble using NSPredicate to create searched contacts array. Can some one guide me on how to do it?
After this,
filteredContacts
will contain only the contacts whosecontact_type
is42
.If you need to search for more than one kind of
contact_type
, then simply use anOR
in the predicate:This solution work cool for me.
//NSDictionary Format
//Step 1
//Step 2: numberOfRowsInSection
//Step 3: In cellForRowAtIndexPath method
Dave's answer above is perfect, I am just adding here what I learned after spending 3 hours of my night sleep.
When you are trying to search string values within dictionary of an array yo need to use predicate something like this:
Don't forget wrapping your values with '', this was the only thing that cost me all the time. Here is my final search function