我拥有一个NSString
,UIImage
和BOOL
属性的personObject。我想创建一个通过只是NSString
通过数组中的某个对象进行过滤
personObject *person1 = [[personObject alloc]initWithName:@"John Smith" Photo:nil Invited:false];
personObject *person2 = [[personObject alloc]initWithName:@"Peter Smith" Photo:nil Invited:false];
personObject *person3 = [[personObject alloc]initWithName:@"Paul Smith" Photo:nil Invited:false];
[self.peopleArray addObject:person1];
[self.peopleArray addObject:person2];
[self.peopleArray addObject:person3];
- (void) filterContententForSearchText: (NSString *) searchText scope:(NSString *) scope{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", searchText];
self.searchArray = [self.peopleArray filteredArrayUsingPredicate:predicate];
}
人民数组包含personObjects过滤器谓词。
'@“self.stringNameProperty startswith [c]%@”'? – Larme 2014-09-22 12:45:44
nope没有工作 – Peter 2014-09-22 19:39:58
任何错误信息? – Larme 2014-09-22 19:41:20