On Tue, Sep 2, 2008 at 4:46 PM, David Alter <[EMAIL PROTECTED]> wrote:
> I have a situation where it would make a lot of sense to have a nibless
> application. I think this situation is unique and would suspect that very
> few people would need to do this. There is some information on how to do
> this. Lap Cat Software has some good information on this
> <http://lapcatsoftware.com/blog/2007/06/04/working-without-a-nib-part-2-also-also-wik/>.
> The example does a few things that makes me question if this is the way to
> go. That brings me to my question.
>
> Is there a supported way to make nibless applications?

Nope!

I'd suggest you reconsider. Nibs aren't nearly the hardship that many
people think they are. There are generally three reasons why people
want a nibless application, in my experience:

1) They want total control over the application, and to set up
everything in code.

But you can still do this with a nib. You can have a MainMenu.nib
which contains nothing besides a rather empty menu bar and whatever
other necessary objects, then set the rest up in code once it loads.

2) They are creating a non-bundled application and so can't store the
nib in the Resources folder.

This is no problem. Although the "standard" Cocoa application loads
the nib automatically by simply declaring the name in the Info.plist
and calling NSApplicationMain, you don't have to do this. You can use
the NSNib class to load a nib from any location, so you can store it
along with the rest of your auxiliary resource files, wherever they
may be.

3) They are creating a pure standalone binary with no external files at all.

This one is a little trickier, but you can still load a nib that you
store inside your application. (Note: I haven't actually done this
one, nor heard of someone who has. It *should* work just fine....)

The trick is to take advantage of NSNib's support for the NSCoding
protocol. Create a regular nib file, create an NSNib from it, then
archive the NSNib instance using NSKeyedArchiver. Take the resulting
data and embed it in your program. (These steps would obviously take
place as part of your build process, not as part of the final
product.) Then when your program starts, it can use an
NSKeyedUnarchiver to reconstitute the NSNib instance, then load that
NSNib instance and off you go.

Mike
_______________________________________________

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