Fast way to search the properties of objects in an NSArray

后端 未结 2 1068
滥情空心
滥情空心 2021-01-27 02:52

I have an NSArray of custom objects that all have a @property name of type NSString. How can I quickly enumerate through the array and cre

2条回答
  •  梦谈多话
    2021-01-27 03:04

    NSString *searchString = @"dog";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.name contains %@", searchString];
    NSArray *filteredArray = [testArray filteredArrayUsingPredicate:predicate];
    

提交回复
热议问题