0

Is it possible to code this sequence of events once an iPhone app has been launched?

  • User launches application.
  • AppDelegate.m checks if data is present in internal database.
  • If yes, MainWindow.xib loads.
  • If no, AnotherViewController.xib loads.

I've only seen app examples that load the MainWindow.xib without conditions.

If it is possible, which method in AppDelegate.m handles the logic? (applicationDidFinishLaunching? viewDidLoad?)

Bart
  • 19,692
  • 7
  • 68
  • 77
JP.
  • 5
  • 1

1 Answers1

1

I don't think you want to load the MainWindow conditionally. Instead, load and show a viewController conditionally. This can be done in applicationDidFinishLaunching.

Justin Gallagher
  • 3,242
  • 21
  • 25
  • Got it! Here's the bit o' code I found that works well in applicationDidFinishLaunching: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *firsttime = [defaults stringForKey:@"firsttime"]; if (firsttime == nil) { //first time firing code goes here NSLog(@"so, this is your first time, huh?"); [defaults setObject:@"lasttime" forKey:@"firsttime"]; – JP. Oct 22 '09 at 02:54