Re: Is awakeFromNib REALLY first to run?
Re: Is awakeFromNib REALLY first to run?
- Subject: Re: Is awakeFromNib REALLY first to run?
- From: Vince DeMarco <email@hidden>
- Date: Fri, 29 Jun 2001 23:11:09 -0700
On Friday, June 29, 2001, at 07:29 PM, email@hidden wrote:
>
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).
>
numberOfRowsInTableView will probably get called as soon as the
dataSource outlet is set on the tableView, At that point it will get
called.
awakeFromNib will get called 1 on every object that is in the nib file
right after the nib file is loaded.
>
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
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev