• 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
Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView


  • Subject: Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
  • From: Keary Suska <email@hidden>
  • Date: Thu, 25 Jun 2009 19:54:16 -0600


On Jun 25, 2009, at 7:33 PM, Peter Zegelin wrote:

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?

There is no such guarantee for -awakeFromNib. You either need to set the value earlier, or call -reloadData on the table.


Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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: Peter Zegelin <email@hidden>
References: 
 >NSViewController awakeFromNib and NSTableView numberOfRowsInTableView (From: Peter Zegelin <email@hidden>)

  • Prev by Date: Substituting characters in a UITextField
  • Next by Date: Re: Substituting characters in a UITextField
  • Previous by thread: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
  • Next by thread: Re: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView
  • Index(es):
    • Date
    • Thread