我正在尝试使用下面的谓词过滤PFUsers
数组,但这不起作用。每当我在UISearchBar中输入一个字符时,NSLog都会显示空数组。有什么我不了解NSPredicate如何运作?
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"username contains %@",searchText];
_searchResults = [[_messages filteredArrayUsingPredicate:resultPredicate] mutableCopy];
NSLog(@"_searchResults: %@",_searchResults);
}
我的PFUser对象数组
2014-01-29 22:46:19.667 My-App[28fg8:70c] messages: (
"<PFUser:X5819CS5:(null)> {\n email = \"useremail@gmail.com\";\n emailVerified = 0;\n username = JohnSmith10;\n}"
)
在搜索栏中输入“De”的结果
predicate: username CONTAINS[c] "De"
2014-01-30 00:35:25.727 My-app[34fg8:10c] searchtext: De