Caplin YT
Caplin YT

Reputation: 265

Objective-c: Not getting the right text on NSArray

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 simulator

on the NSLog enter image description here

Thanks

Upvotes: 1

Views: 37

Answers (1)

Abdelahad Darwish
Abdelahad Darwish

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

Related Questions