1

次のコードは正常にビルドされ、私には問題ないように見えますが、機能しません...キー値コーディングに不慣れであり、あなたの助けが大いに感謝されることを忘れないでください...テーブルビューデリゲートdidSelectRowAtIndexPath:メソッドはこちらカテゴリリストは、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.

4

1 に答える 1

0

[rootDict allKeys]; //これはNSStringの配列であり、NSDictionaryの配列ではありません

このコードは機能しません

NSArray *allRootKeys = [rootDict allKeys];
NSDictionary *newDict = [allRootKeys objectAtIndex:index]; 
于 2009-06-18T08:01:21.680 に答える