Archive for » February 11th, 2010«

Predicates looking for Name

Sorted out the search text criteria for search list.  But the search expression is currently too crude.  Need a better way to identify words within name.

Using the basic like[c] expression which is grossly inadequate.  Maybe regular expression or a combination of predicate complex expressions to cater for this.

Found a nice solution for this iTunes like search from Cocoa Is My Girlfriend.

Overkill with above solution; just use @”x contains[c] %@” will do.

Using Predicates for Search and Core Data

Most search are based on existing table data that is fetched.  This involves creating another list filtered on the existing list.  This is alright for small list.  For bigger list in terms of thousands of items, you need to justify that memory space in maintaining two sets of list.  Memory is always a premium in iPhone.

The usual fetch request when using is great for the initial list.  For searchable  list based on the UISearchBar, you are likely to type in the criteria string for the list.  This is where predicates will be most useful.  You can setup a predicate based on your search text and pass it as a parameter in your predicates before fetching the search list.

This has the advantage of having a single round trip in fetching the new list.  Also, you do not need to create two lists for the usual search.  That being said, now I need to put this into action.