Re: NSApp problem outside of bundle
Re: NSApp problem outside of bundle
- Subject: Re: NSApp problem outside of bundle
- From: "Stephen J. Butler" <email@hidden>
- Date: Mon, 29 Jun 2009 16:18:53 -0500
On Mon, Jun 29, 2009 at 10:21 AM, Peter
Mulholland<email@hidden> wrote:
> I am not using NSApplicationMain() as this would attempt to load the original app's nib. Instead I do this:
>
> int main(int argc, char *argv[])
> {
> [[NSAutoreleasePool alloc] init];
> [NSApplication sharedApplication];
>
> if ([NSBundle loadNibNamed:@"RegDialog" owner:NSApp]) // Load our bundle
> {
> NSData *icon_data = [NSData dataWithBytes:Security_icns_data length:sizeof(Security_icns_data)];
> NSImage *icon = [[NSImage alloc] initWithData:icon_data];
>
> if (icon)
> [NSApp setApplicationIconImage:icon];
>
> [NSApp run];
> }
> else
> {
> ShowDialog(NSCriticalAlertStyle, "Couldn't load RegDialog.nib\n\nTry reinstalling the application. If this fails please contact Support.");
> return 1; // Stop stub relaunching us
> }
>
> return 0;
> }
I agree this is a little nuts. But you should be calling
NSApplicationLoad() to initialize NSApplication before doing any Cocoa
stuff.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden