[英]ios filter records using nsmutablearray filled with NSDictionary<FBGraphUser>* friend
I want to filter my friends list names. 我想过滤我的朋友列表名称。 I had all friends list in NSMutable array using this method i had list .
使用此方法,我在NSMutable数组中列出了所有朋友列表。
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
friendList = [[NSMutableArray alloc]initWithArray:[result objectForKey:@"data"]];
selectedfriendList =[[NSMutableArray alloc]init];
[Tablefriendlist reloadData];
}];
I want to filter records through textfield but problem I dont know how to use nspredicatewithformat
我想通过文本字段过滤记录,但是问题我不知道如何使用
nspredicatewithformat
I am trying this.. and its not filtering correct searched data. 我正在尝试这个..并且它没有过滤正确的搜索数据。
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.first_name contains[c] %@",searchText];
friendList = [NSMutableArray arrayWithArray:[friendList filteredArrayUsingPredicate:predicate]];
NSLog(@"friendlist %@",friendList);
[Tablefriendlist reloadData];
I want to get friendslist that match searchtext 我想获得与搜索文本匹配的朋友列表
problem is its fetching record but those record which contains searched characters only those. 问题是其获取记录,但是那些仅包含搜索字符的记录。 eg i searched sa
例如我搜索了
so it fetches records that contain character 's' and character 'a' i want to seach records with sa eg :: 所以它获取包含字符“ s”和字符“ a”的记录,我想用sa来查找记录,例如::
when 'sa' is searched these records should be fetched
1:falsa
2:telsa
3:salad
what is happening in my code is this
1:falsa
2:telsa
3:yalst
4:salad
Try this 尝试这个
change predicate 变更谓词
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.first_name contains[c] %@",searchText];
to 至
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"first_name contains[c] %@",searchText];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.