【发布时间】:2013-02-08 21:20:18
【问题描述】:
如何使用 NSMutableArray 准备ForSegue?
NSMutableArray *theNews;
这是 prepareForSegue 代码
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSManagedObject *object = [[theNews objectAtIndex:indexPath.row] objectAtIndexPath:indexPath];
[[segue destinationViewController] setDetailItem:object];
}
}
如果我运行代码我得到这个错误:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSDictionaryM objectAtIndexPath:]:无法识别的选择器已发送到实例 0x81c0f40”
【问题讨论】:
-
你在 [[segue destinationViewController] setDetailItem:object]; 线上遇到错误了吗?
-
显然theNews实际上是一个字典,而不是一个数组。你在哪里创建的?
标签: iphone ios xcode uitableview