我为自己确定的一个基本错误而疯狂,但我找不到它。我有简单的代表,除此代表外,其他所有方法都有效。与正常处理方式相比,我看不出任何差异。
@interface MasterViewController () <DetailViewControllerDelegate, SettingsViewControllerDelegate>
@end
@implementation MasterViewController
....
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"ShowSettings"]) {
// here settingsViewController._delegate is 0x075...
// why? where is this coming from?
SettingsViewController *settingsViewController = [segue destinationViewController];
// here settingsViewController._delegate is 0x00000 which I would expect
[settingsViewController setDelegate:self];
// here settingsViewController._delegate is still 0x0000 -- why?
}
}
最佳答案
您确定-[SettingsViewController委托]的支持iVar是_delegate吗?您可能有一个@syntehsize委托;导致iVar只是“委托”的行。在调用setDelegate:之后,在调试器中尝试“ p * settingsViewController”,并确保您没有更多的实例变量。
关于objective-c - 委托(delegate)对象在设置之前已存在于目标 View Controller 中,但在设置之后为0x000..。为什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12417581/