I have the following json object is stored as self.pElements. I have a search bar to be used to filter items based on the name.
[
{"id":"1","name":"Baked Chicken","category":"1","price":"5.49"},
{"id":"2","name":"Beef Kabob","category":"2","price":"5.49"},
{"id":"3","name":"Beef Gyro","category":"1","price":"5.49"},
{"id":"4","name":"Lamb Gyro","category":"4","price":"5.49"}
]
I try to filter by name as follows, but it always returns me null. even I type just Beef, nothing has been returned
pTempElements =[[NSMutableArray alloc] initWithArray:[self.pElements filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", self.searchBar.text]]];
name ==> it means a "perfect match". you may want to replace it withname BEGINSWITH[c](the [c] being for case insenstive in order to "beef" be okay. - LarmeGyroonly? - casillas