NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
- Subject: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
- From: Peter Zegelin <email@hidden>
- Date: Fri, 26 Jun 2009 11:33:46 +1000
Hello,
I have come across what seems to be a weird situation and can't
really think of a good solution. I'm relatively new to Cocoa so its
probably just a simple misunderstanding.
I have a subclass of NSViewController that also acts as the delegate
for the NSTableView that it controls. This tableview is loaded into my
main window. I want to be able to hide some columns in the tableview
and as a result, the number of rows in the tableview will vary
according to numColumns. ie:
-(int)numberOfRowsInTableView:(NSTableView *)tableView{
return myDataSize/numColumns;
}
Now, I haven't got around to actually varying the number of columns in
the table yet, but I do have a property 'numColumns' that I set to a
reasonable value in awakeFromNib:
- (void)awakeFromNib{
numColumns = 8;
}
Unfortunately my numberOfRowsInTableView is being called 'before'
awakeFromNib, so initially numColumns = 0 and I get an error
(myDataSize/numColumns will be infinite).
I always thought awakeFromNib would get called first. But in this case
not so. So can anyone suggest why, and a workaround?
thanks!
Peter
_______________________________________________
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