我在Objective C中有點弱我承認,我的最終目標是將數據從ViewController3傳遞迴ViewController1。事實上,這部分已經完成並取得成功。但是,當調用[self.navigationController popToRootViewControllerAnimated:YES]時,我得到EXC_BAD_ACCESS。使用委託時彈出ViewControllers
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'? –
是的,很抱歉..當我複製/粘貼我的代碼時發生錯字。現在編輯。 – xhermit