Querying Core Data with Predicates - iPhone

后端 未结 4 1201
故里飘歌
故里飘歌 2020-12-25 08:56

So I\'m trying to fetch objects from core data. I have list of say 80 objects, and I want to be able to search through them using a UISearchBar. They are displayed in a tab

相关标签:
4条回答
  • 2020-12-25 09:04

    In typical Core Data application one should delete NSF fetchedResultsController:

    [NSFetchedResultsController deleteCacheWithName: [self.fetchedResultsController cacheName]];
    

    Or else you'll get an exception (ideally) or you'll have strange behavior.

    0 讨论(0)
  • 2020-12-25 09:05

    use contains[cd] instead of like, and change:

    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"All"];

    to:

    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"1=1"];

    0 讨论(0)
  • 2020-12-25 09:08

    Did you try it using MATCH and regular expressions? Just curious to see if LIKE is something that should be avoided on the iPhone or not...

    0 讨论(0)
  • 2020-12-25 09:26

    It seems as though iPhone doesn't like the LIKE operator. I replaced it with 'contains[cd]' and it works the way I want it to.

    0 讨论(0)
提交回复
热议问题