I need to set a property of an NSView loaded from a Nib calculated using its initial bounds. Its bounds is still null inside - (void)awakeFromNib, so what is the first开发者_如何学编程 point in the view's lifecycle that I can access its bounds?
Set it in -viewDidMoveToWindow:
Indeed, Apple documentation clearly says:
Important: Because the order in which objects are instantiated from an archive is not guaranteed, your initialization methods should not send messages to other objects in the hierarchy. Messages to other objects can be sent safely from within awakeFromNib—by which time it’s assured that all the objects are unarchived and initialized (though not necessarily awakened, of course).
On iOS you would use the viewDidLoad
method but it seems that is not necessarily avaible on Mac.
I believe you will find your answer in the stackoverflow post (this is a Mac developer solution specific not iOS but it seems it is what you are looking for).
精彩评论