以下代码已成功构建,对我来说似乎还可以,但不起作用...请注意,我是键值编码的新手,您的帮助将不胜感激...在表格视图中委托 didSelectRowAtIndexPath: 方法在这里categoriesList 是一个包含 5 个条目的简单表格
NSUInteger row = [indexPath row];
NSString *rowString = [categoriesList objectAtIndex:row];
NSString *path = [[NSBundle mainBundle] pathForResource:@"DataBase" ofType:@"plist"];
NSDictionary *rootDict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSArray *allRootKeys = [rootDict allKeys];
NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
for (NSString *name in allRootKeys) {
NSInteger index = [allRootKeys indexOfObject:name];
NSDictionary *newDict = [allRootKeys objectAtIndex:index];
if ([newDict valueForKey:@"Class"] == rowString)
[mutableArray addObject:[allRootKeys objectAtIndex:index]];
}
NSArray *childControllerArray = [[NSArray alloc] initWithArray:mutableArray];
现在我将 childControllerArray 传递给我的下一个控制器的 loadArray ivar,当使用特定数组选择任何行并显示该数组的内容时,它会被推送。当我删除上面的代码并将一个简单的对象数组传递给它,它工作得很好....请帮助
给出的例外是:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSCFString 0x543eb0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key Class.