Re: Writing application without Interface Builder
Re: Writing application without Interface Builder
- Subject: Re: Writing application without Interface Builder
- From: Bill Bumgarner <email@hidden>
- Date: Fri, 21 Jul 2006 19:52:15 -0700
... lots of conjecture about threading, appkit, & the main menu
deleted ...
OK -- it is pretty clear from your post that you don't have an full
understanding of the interaction between the AppKit, Threads, and the
Main Menu. Perfectly on topic, here. The documentation covers some
of this, but not in terms from your codebase's perspective (or nearly
as blunt as I'm about to be). What follows are some relatively
random bits of info that are relevant, but not necessarily a cohesive
idea. Hopefully, it will help you to frame the problem and ask some
more specific questions.
Threading and the AppKit:
The AppKit needs a running run loop to function. That runloop needs
to be running in the main thread -- the initial thread that was used
to start the app. While a growing chunk of the AppKit is threadsafe,
it is -- by and large -- not thread safe. The documentation will
explicitly call out what is thread safe.
If you cannot find something that explicitly states a piece of API is
thread safe, then *** it is not thread safe ***. Period. End of
story. No amount of thread locking around said API will make it
thread safe.
NSApplicationMain()
Though a rather odd spot for it, NSApplication's class documentation
indicates that NSApplicationMain() is effectively implemented as
follows:
void NSApplicationMain(int argc, char *argv[]) {
[NSApplication sharedApplication];
[NSBundle loadNibNamed:@"myMain" owner:NSApp];
[NSApp run];
}
In theory, you could replace the -loadNibNamed with the loading of a
NIB that does not contain a main menu and then call NSApp's -
setMainMenu: method. However, the documentation is quite sparse on
the details of going this route. Mostly because there is generally
very little need to do so.
--
Now, given that you state that your multithreading code stops working
after you no longer call NSApplicationMain(), it is very likely that
you haven't constructed the appkit's main event loop -- the runloop
running on the main thread that handles all AppKit events -- correctly.
It isn't clear why you are mixing Carbon and Cocoa. Is your C++
framework a Carbon framework? In any case, you can mix Carbon and
Cocoa, but it is tricky. There is documentation on the http://developer.apple.com/
site.
b.bum
_______________________________________________
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