In my application, a viewController manages a UIWebView. Is is created with the main Storyboard of the application. This app is able to open a rtf email attachment and display it to its UIWebView.
When application is in background, everything is OK. The application delegate method
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
is called and there a method
[viewController loadImportedRTFDocument:url];
is called. The controller loads the document, and displays it.
When application is not in background when user select the attachment in Mail app, its launches correctly. The App delegate openURL is called, and the viewController receives the message to load imported document. But it is not able to display it, since the UIWebView has not been allocated (returns nil pointer).
What I did observe is that the method called by the app delegate is made before the controller received the viewDidLoad message...
How can I be sure that the viewController has been correctly initialized in this situation, and where should I ask the UIWebView to load the NSData object associated with the rtf attachment?