0
所以,我一直在努力讓NSPredicate工作,它應該。但它不會。 我已經通過這個數組決定進行循環測試怎麼來的,我已經得到了這點與測試NSString測試不會評估爲真正的時候它應該
- (void)getItemsForGroup:(NSString *)groupID completion:(MenuQueryBlock)completion{
...
for (NSDictionary *group in [[[[[[self.singleMenuSet objectForKey:@"menuList"] firstObject] objectForKey:@"UnitMenu"] objectForKey:@"data"] objectForKey:@"groups"] objectForKey:@"group"]) {
NSLog(@"test");
NSLog(@"Group MasterGID: %@",[group objectForKey:@"MasterGID"]);
NSLog(@"test_ MasterGID: %@",groupID);
if ([[group objectForKey:@"MasterGID"] isEqualToString:groupID]) {
NSLog(@"Selected Group: %@",group);
}
}
....
completion(....)
}
這裏是「組選」日誌的部分應打印。
2015-09-02 11:42:24.738 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.738 business_sect[3687:144610] test
2015-09-02 11:42:24.738 business_sect[3687:144610] Group MasterGID: 24000039
2015-09-02 11:42:24.738 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.738 business_sect[3687:144610] test
2015-09-02 11:42:24.738 business_sect[3687:144610] Group MasterGID: 24000040
2015-09-02 11:42:24.738 business_sect[3687:144610] test_ MasterGID: 24000040 <----right after this line
2015-09-02 11:42:24.738 business_sect[3687:144610] test
2015-09-02 11:42:24.739 business_sect[3687:144610] Group MasterGID: 24000041
2015-09-02 11:42:24.739 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.739 business_sect[3687:144610] test
2015-09-02 11:42:24.739 business_sect[3687:144610] Group MasterGID: 24000042
2015-09-02 11:42:24.739 business_sect[3687:144610] test_ MasterGID: 24000040
2015-09-02 11:42:24.739 business_sect[3687:144610] test
2015-09-02 11:42:24.739 business_sect[3687:144610] Group MasterGID: 24000043
2015-09-02 11:42:24.739 business_sect[3687:144610] test_ MasterGID: 24000040
那麼,爲什麼不是「選定的組」打印?
'[group objectForKey:@「MasterGID」]'確實是'NSString'還是它是'NSNumber'? – Larme
嘗試使用if([[group objectForKey:@「MasterGIP」] isKindOfClass:[NSNumber class]]),並確定這實際上是一個數字還是一個字符串 –
這是一個'NSString' – Jargen89