Hi,
I have two tableViews in my application.  One works perfectly the other 
doesn't.  For both I use a simple data source.  
The tableView uses numberOfRowsInTableView: (NSTableView *)aTableView to get 
the number of rows by doing a count of the objects in my array.  This number 
happens to be 22.  When I run the program I get a zillion empty rows after my 
22 rows of data.  However if I use the constant 22 as the return value the 
tableView displays 22 rows of my data.  Any idea about what I am doing wrong?
Here is my code: 
    -(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!
    }



    -(id) tableView: (NSTableView *) aTableView objectValueForTableColumn: 
(NSTableColumn *) aTableColumn row: (int) rowIndex
    {
          id returnValue = nil;
        
          if (aTableView == gameScoresTableView)
          {
                LNPlayer *currentPlayer = [playersArray objectAtIndex: 
currentIndex_]; 
                NSMutableArray *tempGameRecordsArray = [NSMutableArray 
arrayWithArray: [currentPlayer gameRecordsArray]];
                
                id theRecord, theValue;
                
                theRecord = [tempGameRecordsArray objectAtIndex:rowIndex];
                theValue = [theRecord objectForKey:[aTableColumn identifier]];
                
                returnValue = theValue;
          }
          else if (aTableView == playerManagementTableView)
          {
                //Which Player?
                LNPlayer *player = [playersArray objectAtIndex: rowIndex];
                //What is the value of the attribute named identifier?
                //returnValue = [player valueForKey: [aTableColumn identifier]];
                if ([[aTableColumn identifier] isEqualTo: @"firstName_"] == YES)
                        returnValue = [player firstName_];
                else if ([[aTableColumn identifier] isEqualTo: @"lastName_"])
                        returnValue = [player lastName_];
                else if ([[aTableColumn identifier] isEqualTo: @"playerName_"])
                        returnValue = [player playerName_];
                else if ([[aTableColumn identifier] isEqualTo: 
@"trebleClefGameLevel_"])
                        returnValue = [NSNumber numberWithInt: [player 
trebleClefGameLevel_]];
                else if ([[aTableColumn identifier] isEqualTo: 
@"altoClefGameLevel_"])
                        returnValue = [NSNumber numberWithInt: [player 
altoClefGameLevel_]];
                else if ([[aTableColumn identifier] isEqualTo: 
@"tenorClefGameLevel_"])
                        returnValue = [NSNumber numberWithInt: [player 
tenorClefGameLevel_]];
                else if ([[aTableColumn identifier] isEqualTo: 
@"bassClefGameLevel_"])
                        returnValue = [NSNumber numberWithInt: [player 
bassClefGameLevel_]];
                else if ([[aTableColumn identifier] isEqualTo: 
@"symbolTextConcentrationGameLevel_"])
                        returnValue = [NSNumber numberWithInt: [player 
symbolTextConcentrationGameLevel_]];
          }
        
         return returnValue;
    }
Any help would be much appreciated.
Thanks,
Brian

Than
_________________________________________________________________
Windows Live™ SkyDrive™: Get 25 GB of free online storage.
http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_SD_25GB_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