Need some best practice advice here...
Navigation based application. Root view is a UITableView where user can drill down to a detail UIViewController (call it VC1). User wants to initiate some task but it may require additional info before it can proceed. If so then VC1 allocs & presents modal VC2 using the "flip" transition holding a strong reference to VC2 in a property.
All fairly standard. Here's where I'm running into trouble. Once user fills out required info in VC2 the app can either continue on to a MFMailComposeViewController
or flip back to VC1. If they continue to MailCompose then when that dismisses it should return to VC1.
VC2 has a weak reference to VC1 and the problem arrises when VC2 tries to dismiss itself and present MFMailComposeViewController
:
[self dismissModalViewControllerAnimated:YES];
[VC1 performSelector:@selector(showMailModalView) withObject:nil afterDelay:0.2];
I get a EXC_BAD_ACCESS on VC1 because, apparently, my weak reference to VC1 has already been dealloc'd even though VC1 has strong reference to VC2!?!
So my question is...how should this be handled? Would the delegate pattern be better? How would that be triggered?
Note: VC1 is quite large and VC2 isn't often needed so I'm trying to keep VC2 as separate as possible from VC1 (including its own NIB).