我的应用程序委托方法中有一些代码应该将对象发送给视图控制器。出于某种原因,尽管它抛出一个错误:“无法识别的选择发送到实例”应用程序委托:发送到实例的无法识别的选择器
在视图控制器我有以下变量设置:
@property (nonatomic, strong) Patient* patient;
在我的应用程序代理的代码如下所示:
UISplitViewController* splitViewController = (UISplitViewController*)self.window.rootViewController;
UINavigationController* patientNavController = [splitViewController.viewControllers objectAtIndex:0];
PatientMasterTableViewController* patientMasterTableViewController = (PatientMasterTableViewController*)[patientNavController topViewController];
PatientDetailViewController* patientDetailViewController = [splitViewController.viewControllers objectAtIndex:0];
Patient* firstPatient = [[patientMasterTableViewController patientArray] objectAtIndex:0];
[patientDetailViewController setPatient:firstPatient];// this line throwing the error
我是新来的iOS,我不太明白为什么它不会让我通过病人对象。谁能帮忙?
您是否在头文件中设置了属性? – gabbler 2014-10-19 05:17:42
添加您正在获取的异常的详细信息 - 它会告诉您选择器是什么以及您尝试将其发送到的对象类型。这将使你能够找出你出错的地方 – Paulw11 2014-10-19 05:29:52
异常的细节: UINavigationController setPatient:]:无法识别的选择器发送到实例0x8fa1380 2014-10-19 15:58:08.136 ORA [946:60b] * **因未捕获异常'NSInvalidArgumentException'而终止应用程序,原因:' - [UINavigationController setPatient:]:无法识别的选择器发送到实例0x8fa1380' – user2787386 2014-10-19 05:35:59