• 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: Outlets Not Connected In awakeFromNib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outlets Not Connected In awakeFromNib


  • Subject: Re: Outlets Not Connected In awakeFromNib
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 03 Mar 2011 13:37:34 +0100

On Mar 2, 2011, at 4:53 PM, glenn andreas wrote:

>
> On Mar 2, 2011, at 3:54 AM, Andreas Grosam wrote:
>
> What's going on is that awakeFromNib is called when the nib containing the object is instantiated.  In this case, it is the main nib (which is where the root view controller "lives").
>
> However, a view controller's nib ("MyRootViewControler.nib") isn't loaded until it is actually needed, at which point the view controller gets "viewLoaded" message, and so, until that time, any connections between the view controller and things loaded from MyRootViewController.nib will be nil.

Yes, this is how it is. However, according the docs:

"When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established."

The object is the root view controller, which happens to be a file's owner for its own nib, which is referenced from this main nib.

At the time awakeFromNib is sent to the root view controller, the root view controller's outlets whose target exists in the main nib are connected. However, none of the outlets whose target objects exist in its corresponding nib "MyRootViewController nib" are connected.

There is nothing in the docs mentioning this case.

> <...>
>
> The whole purpose of having separate nibs is to avoid recursively loading everything all at once - if that view is never displayed (say, on a tab bar controller tab that the user never selects), its nib will never be loaded.
I understand the reason why this externally defined nib isn't loaded. However, awakeFromNib will be sent to the object which is exactly the file's owner of this external nib at the time when the main nib is loaded - as if this file's owner is considered to be "unarchived, instantiated and initialized".

Well, the net effect of this all is, during awakeFromNib, it is NOT guaranteed that ALL the receiver's outlets are connected.   ;)


Regards
Andreas_______________________________________________

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

  • Follow-Ups:
    • Re: Outlets Not Connected In awakeFromNib
      • From: Kyle Sluder <email@hidden>
References: 
 >Outlets Not Connected In awakeFromNib (From: Andreas Grosam <email@hidden>)
 >Re: Outlets Not Connected In awakeFromNib (From: glenn andreas <email@hidden>)

  • Prev by Date: Re: Outlets Not Connected In awakeFromNib
  • Next by Date: Re: Help with simple NSView animation...
  • Previous by thread: Re: Outlets Not Connected In awakeFromNib
  • Next by thread: Re: Outlets Not Connected In awakeFromNib
  • Index(es):
    • Date
    • Thread