Search code examples
objective-cxcodecore-datanssearchfield

filter data that i loaded with core data with NSSearchField


How can i use NSSearchField for filter data that i load into program with core data ?

i want to do that from code not in interface with binding

(please give me tutorial about it)


Solution

  • There is probably not a more authoritative expert (outside of Apple) on Core Data than the folks at cimgf.com. Here's a tutorial that should help you accomplish exactly what you need.

    http://www.cimgf.com/2008/11/25/adding-itunes-style-search-to-your-core-data-application/

    EDIT: You can further filter the data without going back to disk by using another NSPredicate on the array. If you have a NSFetchedResultsController called myFetchController and a NSPredicate named myPredicate you can do the following.

    NSArray * results = [myFecthController fetchedObjects];
    NSArray * filteredResults = [results filteredArrayUsingPredicate:myPredicate];