我有 plist 文件,我正在使用 CHDictionary 来订购它们。当我使用“allKeys”获取密钥时,没有问题。
这是示例:
//1
NSString *pathListNames = [[NSBundle mainBundle] pathForResource:@"menuListNames" ofType:@"plist"];
//2
CHOrderedDictionary *dictName = [[CHOrderedDictionary alloc] initWithContentsOfFile:pathListNames];
//3
NSArray *temp = [dictName allKeys];
NSLog(@"KEY FIRST ONE %@", temp[0]);
但是,当我想获得一些具有指定范围的键时,我决定使用“keysAtIndexes”,如下所示:
//1
NSString *pathListNames = [[NSBundle mainBundle] pathForResource:@"menuListNames" ofType:@"plist"];
//2
CHOrderedDictionary *dictName = [[CHOrderedDictionary alloc] initWithContentsOfFile:pathListNames];
//3
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)];
NSArray *temp = [dictName keysAtIndexes:indexSet];
NSLog(@"KEY FIRST ONE %@", temp[0]);
我遇到这样的异常
“'NSInvalidArgumentException',原因:'-[__NSCFDictionary keysAtIndexes:]:无法识别的选择器发送到实例”。
如果有人能告诉我 keysAtIndexes:indexSet 导致异常的原因,我会很高兴。
提前致谢。