我试图在我的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上返回
ios -  objective-c :无法在NSArray上获得正确的文本-LMLPHP

NSLog
ios -  objective-c :无法在NSArray上获得正确的文本-LMLPHP

谢谢

最佳答案

您的过滤器是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"];
    }
数组

09-30 23:47