Iphone 从prepareForSegue设置UITableView委托和数据源时出错:发件人:

Iphone 从prepareForSegue设置UITableView委托和数据源时出错:发件人:,iphone,ios,uitableview,storyboard,Iphone,Ios,Uitableview,Storyboard,我正在使用prepareforsque:sender:动态设置UITableView的委托和数据源属性,然后将其推送到导航堆栈上。永远不会调用委托方法,Xcode将返回下面的错误。不幸的是,Xcode并没有给我太多的堆栈跟踪信息,唯一能说明什么对象被用作数据源的是uiviewcontrollerrapperview的实例,我认为它可能是由脚本库生成的。有什么想法吗?这难道不可能吗 错误: *由于未捕获异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIVi

我正在使用
prepareforsque:sender:
动态设置
UITableView
的委托和数据源属性,然后将其推送到导航堆栈上。永远不会调用委托方法,Xcode将返回下面的错误。不幸的是,Xcode并没有给我太多的堆栈跟踪信息,唯一能说明什么对象被用作数据源的是
uiviewcontrollerrapperview
的实例,我认为它可能是由脚本库生成的。有什么想法吗?这难道不可能吗

错误:

*由于未捕获异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIViewControllerRapperView tableView:numberOfRowsInSection::无法识别的选择器已发送到 实例0x7f49370'

这是我的密码:

/**
 * Handle the various segues
 *
 * @author Jesse Bunch
 **/
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the selected cell
    NSIndexPath *selectedIndexPath = self.tableView.indexPathForSelectedRow;
    ReportTableViewCell *cell = (ReportTableViewCell *)[self.tableView cellForRowAtIndexPath:selectedIndexPath];

    // Instantiate the selected report's context
    // TODO: Insert error handling here
    Class reportClass = NSClassFromString([cell.reportInfo objectForKey:@"ReportClass"]);
    BaseReportContext *reportContext = [[reportClass alloc] init];
    reportContext.delegate = self;

    // Get the destination options controller
    ReportOptionsTableViewController *optionsController = (ReportOptionsTableViewController *)segue.destinationViewController;

    // Let the report context be the delegate of the options controller
    // The report context should contain all the information needed
    // to display the necessary report customization options
    optionsController.tableView.delegate = reportContext;
    optionsController.tableView.dataSource = reportContext;


}

然后,您是否会尝试以更可靠的方式保留delegate/ds对象(比如将其保留在var/property array/dictionary)?我相信委托不应该被对象保留,可能会发生所有reportContext都被释放的情况。至少日志完全符合内存管理问题的情况,我相信您自己也注意到了。

请您制作一个简单的IsKindof类:[BaseReportContext类]检查并记录[cell.reportInfo objectForKey:@“ReportClass”]对于负面结果?我从控制台添加了一个屏幕截图,以显示类型与预期一致…BaseReportContext是否实现UITableViewDataSource协议?您可以通过设置异常断点来获取异常的堆栈跟踪@杰西·邦奇,谢谢,看起来不错。然后,您是否会尝试以更可靠的方式保留delegate/ds对象(比如将其保留在var/property array/dictionary)?我相信委托不应该被对象保留,可能会发生所有reportContext都被释放的情况。至少日志与内存管理问题完全匹配,我相信您自己也注意到了。