現在、次の plist を使用してドリルダウン テーブル ビューを作成しています。ただし、子の配列を DetailViewController に渡す際に問題が発生しています。
<plist version="1.0">
<dict>
<key>Food</key>
<array>
<dict>
<key>Name</key>
<string>Food</string>
<key>Description</key>
<string>Description about Food.</string>
<key>IconLink</key>
<string>WFImage.png</string>
<key>Children</key>
<array>
<dict>
<key>ChildName</key>
<string>Burgers</string>
<key>ChildDescription</key>
<string>Description of Burgers</string>
<key>ChildIconLink</key>
<string>WFImage.png</string>
<key>ChildImageLink</key>
<string>WFBanner.png</string>
</dict>
<dict>
<key>ChildName</key>
<string>Hot Dogs</string>
<key>ChildDescription</key>
<string>Description of Hot Dogs</string>
<key>ChildIconLink</key>
<string>WFImage.png</string>
<key>ChildImageLink</key>
<string>WFBanner.png</string>
</dict>
</array>
</dict>
以下を使用して、子の配列を詳細ビューに渡すことができました (正しい量の行が表示されます) が、子要素を抽出することはできません。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showMenuDetail"]) {
NSIndexPath *indexPath = [self.menuTableView indexPathForSelectedRow];
HomeDetailViewController *HDViewController = segue.destinationViewController;
HDViewController.foodChildren = [[menu objectAtIndex:indexPath.row] objectForKey:@"Children"];
HDViewController.foodName = [[menu objectAtIndex:indexPath.row] objectForKey:@"Name"];
NSLog(@"Food Children: %@", HDViewController.foodChildren);
}
}
詳細ビューの cellForRowAtIndexPath で次のことを試してみると:
children = [foodChildren objectForKey:@"ChildName"];
cell.textLabel.text = [children objectAtIndex:indexPath.row];
次のエラーが表示されます。
理由: '-[__NSCFArray objectForKey:]: 認識されないセレクターがインスタンス 0x200a7870 に送信されました'
どんな助けでも大歓迎です!!!