所以,我一直试图让NSPredicate工作,它应该。但它没有赢。 我决定循环使用这个数组来测试它是怎么来的,而且我已经通过测试达到了这一点
- (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(....)
}
这是日志的一部分" Selected Group"应该打印。
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
那么为什么选择小组&#34;&#34;选择小组&#34;印刷?
答案 0 :(得分:0)
你能试试吗?
if ([(NSString *)group[@"MasterGID"] hash] == groupID.hash) {
NSLog(@"Selected Group: %@",group);
}