例子:
self.data = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"To Airport",@"TO/AIR", nil] forKeys:[NSArray arrayWithObjects:kName,kCode, nil]],
[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Point-to-Point",@"PTP", nil] forKeys:[NSArray arrayWithObjects:kName,kCode, nil]],[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"From Airport",@"FR/AIR", nil] forKeys:[NSArray arrayWithObjects:kName,kCode, nil]], nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(name CONTAINS[cd] %@)",searchText];
self.searchableData = [self.data filteredArrayUsingPredicate:predicate];
基于此,您可以将 name 替换为 cityName。