我试图在我的plist上捕获一些数据,它有很多记录
在这种情况下,我使用此代码
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;
在Log上一切正常,但在uilabel上返回
在
NSLog
上谢谢
最佳答案
您的过滤器是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"];
}
数组