You have a valid point. However, awakeFromNib is a traditional place to setup observers, etc. Plus, the docs even recommend this:
³Important: It is possible that your datasource methods for populating the outline view may be called before awakeFromNib is called if the datasource is specified in Interface Builder. You should defend against this by having the datasource¹s outlineView:numberOfChildrenOfItem: method return 0 for the number of children when the datasource has not yet been configured. In awakeFromNib, when the datasource is initialized you should always call reloadData (inherited from the superclass NSTableView) on the resulting outline view.² This indicates that they expect you to use awakeFromNib. Of course, this does not mean you cannot do something smarter. As Kyle has so adeptly pointed out, the behavior is actually consistent with the docs for view-based outline views. However, it may not technically be a bug, but is is certainly a potential problem, requiring a work-around (i.e., the blocking flag) to prevent unwanted behavior, or, as you point out, avoiding the use of awakeFromNib. At the very least, IMHO, the docs should have a caveat, such as the above, to forewarn users of this issue. Ideally, they should fix the problem. As such, I have filed this as a bug report, referring to this discussion: 14168920. On 6/16/13 7:23 AM, <sli...@araelium.com> wrote: > On Jun 15, 2013, at 1:32 PM, Gordon Apple wrote: > I still think the compiler > should be smart enough to block this > without having to put a on-shot > blocking flag in awakeFromNib, which I have > now done. My question would be, > why are you using awakeFromNib specifically in the first place? I really do > find that it's not the right place to do things. IMO an instance should not > expect to be loaded from a nib (which means it shouldn't use awakeFromNib), > and any File's Owner which is loading a nib can perform its duties after > loading the nib rather than in its own awakeFromNib. When both of those things > are true, there are better places to do setup work and avoids the whole mess > of trying to manage flags for which awakeFromNib call is mapped to which nib > load. _______________________________________________ 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