SearchDisplayController search multiple arrays

后端 未结 2 1689
情话喂你
情话喂你 2021-01-25 10:42

Currently I\'m populating my tableviewcells with the contents of multiple arrays representing a name, id, etc.

My question comes when I start to use the search display c

2条回答
  •  再見小時候
    2021-01-25 11:19

    You can do that with NSPredicate using KVC object.

    Create an NSObject respond to the KVC scheme http://theocacao.com/document.page/161 . You can use property for that.

    Filter your array with an NSPredicate http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.name LIKE[cd] %@ OR self.alias LIKE[cd] %@",searchString,searchString];
    NSArray *result = [baseArray filteredArrayUsingPredicate:predicate];
    

提交回复
热议问题