• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
      • From: Kyle Sluder <email@hidden>
    • Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
      • From: Graham Cox <email@hidden>
    • Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: GC pros and cons
  • Next by Date: Substituting characters in a UITextField
  • Previous by thread: Re: document specific "as-you-type" spell checking
  • Next by thread: Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
  • Index(es):
    • Date
    • Thread