I want to filter my friends list names. I had all friends list in NSMutable array using this method i had list .
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
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 ::
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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.