Hi Steve, 

Thanks for your help.  You were right it is acting like an unintialized local 
variable.  However when I initialize returnValue to 0 at the beginning of the 
method. 
int returnValue = 0;
I got some new bizarre behavior. In Interface Builder the tableView is set to 
show 9 rows.  Now, with returnValue initialized to 0, when I run the 
application the tableView no longer has a zillion extra rows which is good. 
Rather it only has 9.  No vertical scroll to see the other 13 rows of data.  
Now the tableView is behaving as if I have zero rows.  Yet clearly later in the 
method returnValue is set to 22 via count method applied to my array.  In my 
debugger and in my NSLogs returnValue is 22.  
If at the beginning of the method I initailize returnValue to 22 all looks as 
expected.  Also if at the end of the method I statically set returnValue to 22 
all is well.  It just doesn't seem to work if I set returnValue by using:
returnValue = [playersArray count]; (debugger and NSLog confirm that 
returnValue is set to 22)
I don't understand why?

I really appreciate your other points about my error code -- I never thought 
about what the tableView might do if -1 was returned and now that I think about 
it I don't really want to find out so I changed it to 0.
Thanks,
Brian
CC: cocoa-...@lists.apple.comfrom: puns...@mac.com
Subject: Re: TableView displaying a zillion empty rows
Date: Mon, 6 Jul 2009 12:32:38 -0700
To: brian5hug...@hotmail.com On Jul 6, 2009, at 11:50 AM, Greg Guerin wrote:
 
Brian Hughes wrote:

-(int) numberOfRowsInTableView: (NSTableView *)aTableView
 {
   int returnValue;
  
   if (aTableView == gameScoresTableView) //This works as expected
   {
      if (currentIndex_>= 0)
      {
         LNPlayer *currentPlayer = [playersArray objectAtIndex:  
         currentIndex_];
         NSMutableArray *tempGameRecordsArray = [NSMutableArray  
         arrayWithArray: [currentPlayer gameRecordsArray]];
         returnValue = [tempGameRecordsArray count];
      }
      else
      {
         NSBeep ();
         NSLog (@"ERROR in LNAppController -- numberOfRowsInTableView:");
         return -1;
      }
 
    }
    else if (aTableView == playerManagementTableView) //This is the one that 
doesn't work
    {
         returnValue = [playersArray count];  //[playersArray count] = 22
          NSLog (@"playersArray count = %d", returnValue);  //returnValue  = 22
    }
  
    return returnValue;  //However if I change this to: return returnValue = 22 
it works fine!
 }

>What will returnValue be if aTableView is neither  
>gameScoresTableView nor playerManagementTableView?
>
>Looks like an uninitialized local variable.
> 
> Also, for your error case (table is gameScoresTableView and  
> currentIndex_ is negative), is that a situation you should allow to  
> happen or is that something that could be handled better/differently  
> by the underlying model or within your controller? What does  
> NSTableView do when you tell it there are -1 rows?
> 
> steve
> 

_________________________________________________________________
Windows Liveā„¢: Keep your life in sync. 
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to