• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CocoaInCarbon NSApplicationLoad
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: newbie confused by obj-c syntax
  • Next by Date: Optimising an app for battery power use?
  • Previous by thread: newbie confused by obj-c syntax
  • Next by thread: Optimising an app for battery power use?
  • Index(es):
    • Date
    • Thread