Re: Is awakeFromNib REALLY first to run?
Re: Is awakeFromNib REALLY first to run?
- Subject: Re: Is awakeFromNib REALLY first to run?
- From: Fritz Anderson <email@hidden>
- Date: Fri, 29 Jun 2001 22:39:10 -0500
At 9:29 PM -0500 6/29/2001, email@hidden wrote:
[T]he Oreilly book says that awakeFromNib is always run first.
However, in this code example derived from the books Very Simple
Table, it appears that numberOfRowsInTableView gets run at least a
couple of times. The result is that until I manually resize my
table, I can't access the other items in my table (i.e. vertical
scroll is inactive).
-awakeFromNib is not necessarily the first of your code to run. Some
delegate or override code may get called in the course of
initializing your objects as they load from the nib. It doesn't
surprise me that your controller's numberofRowsInTableView: method
gets called several times as the table is initialized and laid out.
After everything is initialized, and all the outlet and target links
are set up, then awakeFromNib gets called. So think of it as getting
called as soon as your object is open for business.
- (void) awakeFromNib
{
int index;
myArray = [[NSMutableArray alloc] init];
for (index = 0; index < 30; ++index)
{
NSDecimalNumber *myNumber = [NSDecimalNumber numberWithInt:index];
[myArray addObject: myNumber];
[myArray retain];
}
}
The retain problem has already been noted.
My guess on the display problem is that you should send [myTableView
reloadData], assuming your outlet to the NSTableView has that name.
You've changed the shape and content of your table data, and that's
how you tell NSTableView to reformat to match.
-- F
--
Fritz Anderson <email@hidden>
Parallel Software, Inc <
http://www.parallel.com/>
Naperville, Illinois