このような状況では、委任を使用してデータを渡す代わりに、NSNotificationCenterを使用してビュー コントローラー間で通信することを検討してください。
最初のビュー コントローラーで、通知をリッスンするように登録します。
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleFourthViewSubmit:)
name:@"fourthViewSubmit"
object:nil];
}
通知が送信されたときに実行されるメソッドを作成します。
- (void)handleFourthViewSubmit:(NSNotification *)notification {
NSDictionary *theData = [notification userInfo]; // theData is the data from your fourth view controller
// pop views and process theData
}
最初のビュー コントローラーの dealloc メソッドでは、オブザーバーとしての登録を必ず解除してください (潜在的なクラッシュを回避するため)。
-(void) dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
次に、4 つ目のビュー コントローラーで、Enter ボタンが押されたときに通知をブロードキャストします。
// note: dataDict should be an NSDictionary containing the data you want to send back to your first view controller
[[NSNotificationCenter defaultCenter] postNotificationName:@"fourthViewSubmit"
object:self
userInfo:dataDict];