• 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
Re: how to manage two nib files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to manage two nib files


  • Subject: Re: how to manage two nib files
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 10 Dec 2008 02:48:11 -0600

On Dec 8, 2008, at 8:40 AM, XiaoGang Li wrote:

Thanks. I have read these references, but I still have no idea about my
issue, Maybe I did not understand them completely now, but I am worried that
maybe I have not give a clear expression in my first email. Maybe I need
give a more detailed description:


this application is a utility for my printer, which be launched
by the utility button on the Printer Setup Center. when user click the
utility button, the Mac OS X will launch the linked application. and the
application should first register an apple event, the Mac OS X then will
send the apple event which used to tell my utility the printer model name
and related information about the device. So, before the appliction be
launched, it should get the apple event and check the printer name, then it
will load the nib file dependently. If the printer is a USB printer, it will
load a normal window to interact with user, if it is a Network, it will
launch another application to do other things.


So, I have no idea to design this application. I think this
question maybe can not be implemented by cocoa application template, but I
know that it seems no need to use NSDocument class. Thanks.

You don't need to use the Document-based application template.

An application typically has a main nib. This is configured using the Main Nib File field of the Properties tab of the info window for the target. The value of that field gets translated at build time into the NSMainNibFile key in the application's Info.plist file.

The main nib is loaded by NSApplicationMain(). Often it contains the main window of your application, whatever that might be. However, the main nib can be reduced to contain only the main menu bar and nothing else. This allows you to defer the decision about what window to show until you receive the Apple Event you're expecting.

When you do receive it, you can load whatever nib you like. Often, you use a custom subclass of NSWindowController. Have it both load the nib and act as the nib's owner. In your nib, you'd configure the class of File's Owner to be your custom class. You'd connect its window outlet to the main window in that nib. In your application controller, at the time when you realize which nib you want to load, you allocate and initialize an instance of your class, and ask it to show its window. That last step will cause it to load its nib, thereby instantiating the window and showing it.

If for some reason you don't want to use NSWindowController to load the nib, you can use methods of NSBundle or NSNib to load the nib.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >how to manage two nib files (From: "XiaoGang Li" <email@hidden>)
 >Re: how to manage two nib files (From: Kiel Gillard <email@hidden>)
 >Re: how to manage two nib files (From: "XiaoGang Li" <email@hidden>)

  • Prev by Date: CoreData -- addPersistentStoreWithType crashing
  • Next by Date: Re: Weird behavior of mouse location when performing a drag
  • Previous by thread: Re: how to manage two nib files
  • Next by thread: One-way communication from NSPanel in MainMenu.xib to Custom View
  • Index(es):
    • Date
    • Thread