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 <agro...@onlinehome.de> 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 <agro...@onlinehome.de> 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 (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 arch...@mail-archive.com

Reply via email to