Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my app delegate's didFinishLaunchingWithOptions method all of sudden being called AFTER my RootViewController:viewDidLoad method?
    text
    copied!<p>I've been playing with the iPad's SplitView template in Xcode. Here are two of the many important methods that are auto-generated for you by the Split View-based Application template...</p> <p><strong>AppNameAppDelegate.m</strong></p> <pre><code>#pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch rootViewController.managedObjectContext = self.managedObjectContext; // Add the split view controller's view to the window and display. [window addSubview:splitViewController.view]; [window makeKeyAndVisible]; return YES; } </code></pre> <p><strong>RootViewController.m</strong></p> <pre><code>#pragma mark - #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; self.clearsSelectionOnViewWillAppear = NO; self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0); NSError *error = nil; if (![[self fetchedResultsController] performFetch:&amp;error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } } </code></pre> <p>When you build and run the project before making any changes at all, the <code>application:didFinishLaunchingWithOptions</code> method is called before the <code>RootViewController:viewDidLoad</code> method is called. I'm new to iPhone development, but I'm assuming this is the correct and typical sequence. So here are the changes I made... </p> <ul> <li>Once I confirmed everything was working without any modifications, I changed the RootViewController code and set it as a subclass of <code>UIViewController</code> (instead of <code>UITableViewController</code> by default) and made the respective adjustments in Interface Builder. I built and ran, everything was still working fine. </li> <li>Then, I added a UIView (with nothing in it) to the RootView in IB and when I built and ran it, suddenly the <code>RootViewController:viewDidLoad</code> is being called before the <code>application:didFinishLaunchingWithOptions</code> method. </li> </ul> <p>I need to get it back to the way it was working before because, as you can see in the code, the viewDidLoad method depends on didFinishLauchingWithOptions method to execute so it can set the rootViewController's <code>managedObjectContext</code> that it uses to perform the fetch request.</p> <ol> <li>Any ideas what caused this?</li> <li>Any ideas how I can fix this?</li> </ol> <p>Thanks so much in advance for your help! I'm gonna keep researching and playing with the code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload