• 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: Controller and NIB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Controller and NIB


  • Subject: Re: Controller and NIB
  • From: Graham Cox <email@hidden>
  • Date: Wed, 29 Oct 2008 09:23:56 +1100


On 29 Oct 2008, at 9:09 am, J. Todd Slack wrote:

What is a full proof way to have code executed when a NIB is loaded?

When my MainMenu.nib displays its Window, I want to execute some code.


If you have an object in the nib, its -awakeFromNib method will be called. The object can be an instance of any class, say 'MyObject'. However you do have to put that object in the nib - just having it in your code won't do anything because there's nothing instantiating it. You can drag a generic object into your nib in IB and then use the properties inspector to set its class to whatever you want, e.g. 'MyObject'.

Another way if you only need some code to run when the app is launched is to implement an application delegate and override the - applicationDidFinishLaunching: method.

hth,

Graham
_______________________________________________

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: 
 >Controller and NIB (From: "J. Todd Slack" <email@hidden>)
 >Re: Controller and NIB (From: Nick Zitzmann <email@hidden>)
 >Re: Controller and NIB (From: "J. Todd Slack" <email@hidden>)

  • Prev by Date: Re: Message Forwarding Overhead / Performance
  • Next by Date: Re: NSPredicateEditor error
  • Previous by thread: Re: Controller and NIB
  • Next by thread: Re: Controller and NIB
  • Index(es):
    • Date
    • Thread