• 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
TableView displaying a zillion empty rows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TableView displaying a zillion empty rows


  • Subject: TableView displaying a zillion empty rows
  • From: Brian Hughes <email@hidden>
  • Date: Mon, 6 Jul 2009 14:14:44 -0400
  • Importance: Normal

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: TableView displaying a zillion empty rows
      • From: Florian Soenens <email@hidden>
  • Prev by Date: Re: Long term performance of NSConnection
  • Next by Date: Re: How to share Cocoa classes?
  • Previous by thread: NSTokenField asynchronous autocompletion
  • Next by thread: Re: TableView displaying a zillion empty rows
  • Index(es):
    • Date
    • Thread