On 06 Jul 2014, at 08:54, Roland King <r...@rols.org> wrote: > After awakeFromNib all the outlets are connected except for those to subviews > of the UIViewController's view, they remain nil until after viewDidLoad. > Other top-level object outlets are connected, but not the view nor its > subviews. I always felt that broke the awakeFromNib contract; the objects are > in the NIB, the outlets are in the NIB, surely they should be connected at > awakeFromNib.
The contract is that all outlets loaded from the current NIB are connected. If you have cascading NIB loads, then you get an awakeFromNib call for each NIB (at least on the Mac, I don’t think I’ve had nested NIBs on iOS in a while). That means that e.g. a view controller in a NIB will get one awakeFromNib because the items in the NIB it owns have been loaded and connected, and then a second one when its parent NIB has finished loading and it’s been connected to the other items surrounding it. Depending on when the inner view controller is asked to provide its view, it may not have been loaded yet, so obviously there’s nothing to connect to yet. E.g. if the surrounding NIB calls -view on the view controller in -awakeFromNib, then of course it is until then that the remaining outlets are connected. I don’t see how that would break any contracts, it is logical. The alternative would be to somehow violate encapsulation and have an inner object inform the outer object that it has a NIB that needs loading as well, and then have it modify the load order and trigger awakeFromNib calls on objects actually instantiated by its owner and … it would be very messy, at the latest once you have a view controller inside the NIB of a view controller inside of the app’s main NIB or whatever. Cheers, -- Uli Kusterer “The Witnesses of TeachText are everywhere...” http://zathras.de _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com