我目前正在使用以下 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'
任何帮助,将不胜感激!!!