On Jul 14, 2008, at 7:29 AM, Jim Crafton wrote:
How do you bootstrap the framework? I.e. what executable is run that uses the resources from the framework? That is the most likely place to stick
the MainMenu.nib and let Cocoa bootstrap the normal way.

Well you'd create your standard C++ app in Xcode (with standard app
settings, i.e. you're creating a full blown .app bundle, not a unix
command line utility), and then link to my libraries as Frameworks
(i'd like to offer the possibility to link statically, but I'm 100%
sure about how to do that). Given that I've created my libraries as
Frameworks, can I have a .nib as part of one of the Framework bundles?
My framework is laid out like so:

FoundationKit.framework
GraphicsKit.framework (depends on FoundationKit.framework)
ApplicationKit.framework (depends on GraphicsKit.framework)

If you're writing a GUI app, then you'd link to
ApplicationKit.framework (and GraphicsKit.framework +
FoundationKit.framework).  Can I have a MainMenu.nib file in the
ApplicationKit.framework? That way it's all built in and the developer
doesn't have to worry about creating it.

Yes, you can.

If you look at NSApplication's documentation, you can replace main() in a Cocoa project with:

int main(int argc, char *argv[])
{
    [NSApplication sharedApplication];
    [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
    [NSApp run];
    return 0;
}

(I just tested it :).

So, replace the -loadNibNamed:owner: with the loading of the NIB from your framework.

Actually, reading the docs for +loadNibNamed:owner:, I think it is even easier (but you'll want to test it). The owner is used to determine where to look for the NIB.

If you were to create a subclass of NSApplication that lives within the framework that has your generic MainMenu.nib and then set the application class of your application to that subclass, then the standard means of bringing up Cocoa -- i.e. the call to NSApplicationMain() -- should "just work".

That is, clients of your framework should be able to:

- create a new Cocoa application project

- delete MainMenu.nib

- set the application class to your custom NSApplication subclass

- link against your framework

Build & run.

b.bum


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to