Reputation: 265
i am trying to catch some data on my plist , it has a lot of records
for that case i used this code
NSString *path = [[NSBundle mainBundle] pathForResource:@"kurdiebg" ofType:@"plist"];
NSArray *plistData = [NSArray arrayWithContentsOfFile:path];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"english = %@", self.searchQwery.text];
NSArray *filtered = [plistData filteredArrayUsingPredicate:filter];
NSLog(@"found matches: %@ : %@", filtered,[filtered valueForKey:@"kurdi"]);
NSString*nss = [NSString stringWithFormat:@"%@",[filtered valueForKey:@"english"]];
self.lblWord.text = nss;
its all fine on the Log, but on the uilabel it returns this
Thanks
Upvotes: 1
Views: 37
Reputation: 6067
your filter is array od NSdictionary
NSString *path = [[NSBundle mainBundle] pathForResource:@"kurdiebg" ofType:@"plist"];
NSArray *plistData = [NSArray arrayWithContentsOfFile:path];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"english = %@", self.searchQwery.text];
NSArray *filtered = [plistData filteredArrayUsingPredicate:filter];
NSLog(@"found matches: %@ : %@", filtered,[filtered valueForKey:@"kurdi"]);
NSString*nss = [NSString stringWithFormat:@"%@",[filtered valueForKey:@"english"]];
if (filtered.count>0) {
NSDictionary *dic = filtered[0];
self.lblWord.text = dic[@"english"];
}
Upvotes: 1