0

如何使用 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”

4

1 回答 1

2

theNews您的数组中的数据似乎有点NSDictionary. 没有用 调用- objectAtIndexPath:的方法NSDictionary。您应该– objectForKey:改用(或其他一些方法)

于 2013-02-08T13:20:18.077 回答