CocoaInCarbon NSApplicationLoad
CocoaInCarbon NSApplicationLoad
- Subject: CocoaInCarbon NSApplicationLoad
- From: Kurt Bigler <email@hidden>
- Date: Tue, 15 Mar 2005 01:14:59 -0800
I'm trying to make the CocoaInCarbon sample code into a real application.
This sample app permits multiple Cocoa windows to be created. However, the
multi-window logic has some limitations due to the dependency on the global
variable "sharedController".
I've rewritten the app to eliminate the sharedController global and it is
working fully now, in ways that the sample did not, but I have one concern.
The original app calls NSApplicationLoad from the controller's init method.
This means NSApplicationLoad gets called each time another Cocoa window is
created, which seems wrong. However, if instead of doing this I call
NSApplicationLoad only once from main before entering the event loop, all
the controls in my windows are unresponsive, including the
close/minimize/maximize buttons.
Here's a little snippet from the CocoaInCarbon sample showing the
questionable call to NSApplicationLoad and the use of sharedController:
> static Controller *sharedController;
>
> @implementation Controller
>
> + (Controller *)sharedController {
> return sharedController;
> }
>
> - (id)init {
> self = [super init];
> // initialize NSApplication using an entry point that is specific to bundles
> // this is a no-op for Cocoa apps, but is required by Carbon apps
> NSApplicationLoad();
> if (![NSBundle loadNibNamed:@"MyWindow" owner:self]) {
> NSLog(@"failed to load MyWindow nib");
> }
> sharedController = self;
> return self;
> }
Any ideas?
Thanks in advance.
-Kurt Bigler
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden