Re: variable problem is driving me nuts
Re: variable problem is driving me nuts
- Subject: Re: variable problem is driving me nuts
- From: Kyle Sluder <email@hidden>
- Date: Sun, 28 Oct 2012 01:37:44 -0700
On Oct 27, 2012, at 6:02 PM, Jens Alfke <email@hidden> wrote:
> In general, initialization code like this in a nib-loaded object should go into its -awakeFromNib method, which is [almost] guaranteed to be the first method invoked on that object.
Actually, the NSTableView docs explicitly warn that this is not the case:
> Important: It is possible that your datasource methods for populating the table 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 numberOfRowsInTableView: method return 0 for the number of rows when the datasource has not yet been configured. In awakeFromNib, when the datasource is initialized you should always call reloadData on the table view.
Initialize your instance variable in -init, which *is* guaranteed to be the first method called on your object.
--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