• 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: Is awakeFromNib REALLY first to run?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Is awakeFromNib REALLY first to run?
      • From: Gerard Iglesias <email@hidden>
References: 
 >Is awakeFromNib REALLY first to run? (From: email@hidden)

  • Prev by Date: Drag and Drop and NSTextFieldCell
  • Next by Date: Shadowed Text
  • Previous by thread: Re: Is awakeFromNib REALLY first to run?
  • Next by thread: Re: Is awakeFromNib REALLY first to run?
  • Index(es):
    • Date
    • Thread