在獲取nsmutable數組內容的時候,如果不用NSString查詢一切正常:
NSLog(@"user information %@", [usersInfo filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"%K == 'Joe", @"id"]]);
但是如果用NSString查詢就會出問題:
NSString *user="Joe";
NSLog(@"user information %@", [usersInfo filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"%K == user", @"id"]]]);
不知道為什麼?
使用
NSLog(@"user information %@", [usersInfo filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%K == '%@'",@"id",user]]]);