saidozcan
saidozcan

Reputation: 2215

Determine which UIViewController runs first

I started to learn objective-c and ios programming.I have two View Controller which are named MainViewController and GameViewController,also there are two xib files in my project.I connected xib files with the ViewController's.Totally Here are my files:

View Controllers,

    AppDelegate.h
    AppDelegate.m
    MainViewController.h
    MainViewController.m
    GameViewController.h
    GameViewController.m

and xibs,

    Main.xib
    Game.xib

I choose Main.xib as main interface in the project options.I'm trying to understand questions below,when i run this application first main.m runs.Thats okay.

After that does the AppDelegate class runs?How xcode determines which View Controller will run first?

With this project when i run,there is only black screen.Can anyone help me about an ios application's run order?

Upvotes: 0

Views: 106

Answers (1)

CodaFi
CodaFi

Reputation: 43330

Xcode doesn't determine anything, it's entirely up to you to set up your UI after

-application:didFinishLaunchingWithOptions:launchOptions 

is called by the system. Below is an example where ExampleViewController is initialized first:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ExampleViewController alloc] initWithNibName:@"ExampleViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

The Application initialization flow is:

main() -> AppDelegate (or whatever class has been designated the delegate) -> initial view controller

Upvotes: 3

Related Questions