【发布时间】:2012-12-27 05:56:43
【问题描述】:
我承认我的 Objective C 有点弱,我的最终目标是将数据从 ViewController3 传递回 ViewController1。实际上,这部分已经完成并且成功了。然而,当调用 [self.navigationController popToRootViewControllerAnimated:YES] 我得到 EXC_BAD_ACCESS。
ViewController1 <ViewController2Delegate>
- (void) didAddEventLocation:(Event *)event {
NSLog(@"Event name = %@", event.name); //Shows name successfully
}
ViewController2 <ViewController3Delegate>
- (void) didAddEvent:(Event *)event {
[self.delegate didAddEventLocation:event];
}
ViewController3
[self.delegate didAddEvent:event];
[self.navigationController popToRootViewControllerAnimated:YES];
抱歉,代码格式不正确,只是为了简化。做 [self.navigationController popViewControllerAnimated:YES] 没有问题,但它只需要我到 ViewController2。我知道我在这里做错了什么,但不能完全确定如何解决它。如果我需要澄清,请告诉我。
【问题讨论】:
-
你确定
[self.delegate didAddEventLocation:eventTmp];是正确的,因为参数是event? -
是的,抱歉.. 是我在复制/粘贴代码时打错了字。立即编辑。
标签: ios objective-c inheritance delegation