Search code examples
iphonexcodesdkjailbreakuiwindow

Adding a UIWindow in xcode iPhone SDK


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?


Solution

  • If you want to launch an app from a daemon, use SBSLaunchApplicationWithIdentifier.

    BOOL SBSLaunchApplicationWithIdentifier(NSString* identifier,
                                            BOOL      please_pass_NO_here);
    

    If you want to launch a URL, use -[UIApplication openURL:] or the lower-level GSEventSendApplicationOpenURL.

    mach_port_t GSGetPurpleSystemEventPort();
    void GSEventSendApplicationOpenURL(CFURLRef url, mach_port_t port);
    

    If you simply want to display an alert, use CFUserNotification. (Yes it works on iPhoneOS.)

    http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFUserNotificationRef/Reference/reference.html