Is awakeFromNib REALLY first to run?
Is awakeFromNib REALLY first to run?
- Subject: Is awakeFromNib REALLY first to run?
- From: email@hidden
- Date: Fri, 29 Jun 2001 21:29:54 -0500
Hi all,
I've been playing around with Cocoa, trying to get through the Oreilly
book, and I've come across something that doesn't seem right. Although
the 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).
So what am I missing (other than a complete understanding of Objective
C!)?
- (void) awakeFromNib
{
int index;
myArray = [[NSMutableArray alloc] init];
for (index = 0; index < 30; ++index)
{
NSDecimalNumber *myNumber = [NSDecimalNumber
numberWithInt:index];
[myArray addObject: myNumber];
[myArray retain];
}
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
// printf("Arraysize = %d\n", [myArray count]); // when uncommented,
prints zeros in the console THEN 30
return [myArray count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
return [myArray objectAtIndex: row];
}
Lloyd
---
Canna Software Development