adding UIWindow in xcode iPhone SDK

Discussion in 'iOS Development' started by raziiq, Jan 5, 2010.

  1. raziiq

    raziiq New Member

    Aug 23, 2009
    Likes Received:
    Hi there.

    I am creating a project in which i have to change the main.m file, so that UIApplication doesnt appear straight away, so i deleted the following line from main.m

     int retVal = UIApplicationMain(argc, argv, nil, nil);
    and deleted these lines from AppDelegate

    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
        // Override point for customization after application launch
        [window makeKeyAndVisible];
    And i have added some lines of mine. Now UIWindow doesnt appear by default, and rightly so. But now after my code is executed, i want to create a Window and display some message.

    How to create a UIWindow when there is no UIApplication in main.m?
  2. lauNchD

    lauNchD Well-Known Member

    Jan 27, 2008
    Likes Received:
    iPhone 5 (Black)

    If you want to change your application's "launch behavior," you should have a semi-solid understanding of how Cocoa Touch works. You cannot create a GUI application without using UIApplication routines (except if you're some kind of ├╝ber-hacker and like fiddling around with private frameworks like GraphicsServices, which is strictly forbidden by Apple).

    UIApplicationMain() must be called, because it sets up the application's flow & run loop. If you don't want to show your main window directly after launch, just don't create it or just don't send makeKeyAndVisible. Or, make your own app delegate and load a window from a nib if you want to. If you just want to delay the launching time, add your custom code into applicationDidFinshLaunching; it's in the main thread so it blocks all display changes until it's done.

Share This Page