• 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: Fri, 04 Mar 2011 10:21:38 +0100

All,

thank you for your replies. It made me re-read the Resource Programming Guide. And it works exactly as it is described (except that the description for -awakeFromNib in the Reference could be more accurate). Though, I have mixed feelings about how it works.

Unfortunately, due to the problem described previously, -awakeFromNib does not seem to be always appropriate for its intended use as described in the reference. There are also subtle differences between iOS and Mac OS.

On iOS, when using -viewDidLoad, we need to consider that it can possibly be called more than once in the life cycle for a controller, and may be created from within a nib or programmatically. This often requires extra care in this and possibly related methods, e.g. -viewDidUnload. So, unfortunately, there is no easier way.


Andreas


On Mar 3, 2011, at 5:57 PM, Kyle Sluder wrote:

> On Thu, Mar 3, 2011 at 4:37 AM, Andreas Grosam <email@hidden> wrote:
>> 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.
>
> -awakeFromNib is sent to every object in the nib after all the
> connections defined in the nib have been established. Since cross-nib
> connections are not allowed, the documentation has no need to mention
> your scenario.
>
> Perhaps the documentation should be rephrased to say "all connections
> defined in the nib are guaranteed to have been reestablished" rather
> than guaranteeing that all outlets have been connected, which is
> inaccurate.
>
> On Thu, Mar 3, 2011 at 4:27 AM, Andreas Grosam <email@hidden> wrote:
>> When -awakeFromNib is sent to the root view controller, the outlet 'testView' is not connected. The message is sent during *loading the main nib*. The root view controller does not receive another -awakeFromNib message.
>
> From the Resource Programming Guide:
>
> "In iOS, this message [-awakeFromNib] is sent only to the interface
> objects that were instantiated by the nib-loading code. It is not sent
> to File’s Owner, First Responder, or any other proxy objects."
>
> So the answer to your problem is use the UIViewController methods to
> find out when your RootViewController has loaded its view.
>
> --Kyle Sluder

_______________________________________________

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: 
 >Outlets Not Connected In awakeFromNib (From: Andreas Grosam <email@hidden>)
 >Re: Outlets Not Connected In awakeFromNib (From: glenn andreas <email@hidden>)
 >Re: Outlets Not Connected In awakeFromNib (From: Andreas Grosam <email@hidden>)
 >Re: Outlets Not Connected In awakeFromNib (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: table view and custom cell optimization problem
  • Next by Date: Re: table view and custom cell optimization problem
  • Previous by thread: Re: Outlets Not Connected In awakeFromNib
  • Next by thread: Re: Outlets Not Connected In awakeFromNib
  • Index(es):
    • Date
    • Thread