On Jul 8, 2009, at 1:36 AM, Brian Hughes wrote:
So I changed my code to reflect Quincy Morris's recommendations.

Something removed the indentation from your code, so I've re-added it below:

-(int) numberOfRowsInTableView: (NSTableView *)aTableView {
        if (aTableView == gameScoresTableView) //This works as expected
        {
LNPlayer *currentPlayer = [playersArray objectAtIndex: currentIndex_]; NSMutableArray *tempGameRecordsArray = [NSMutableArray arrayWithArray: [currentPlayer gameRecordsArray]];
                return [tempGameRecordsArray count];

A side note, not related to your problem: there's no reason to make a copy of the gameRecordsArray. You could say

NSMutableArray *tempGameRecordsArray = [currentPlayer gameRecordsArray];
                return [tempGameRecordsArray count];

or simply

                return [[currentPlayer gameRecordsArray] count];

        }
        else if (aTableView == playerManagementTableView)
        {
NSLog (@"playersArray count = %d", [playersArray count]); // [playersArray count] = 22
                return [playersArray count];
        }
        else
        {
                NSLog (@"Invalid table view");
                return 0;
        }
}

There's another part to your code that we haven't seen, which is your tableView:objectValueForTableColumn:row: method. Out of curiosity, can you show us that code? I assume it is similarly structured to handle the two table view cases. If you put an NSLog in the playerManagementTableView case, is it not called 22 times?

The results you've described "can't" be happening, because it seems you're doing everything right. If you want to send me your project off-list I'd be happy to try to track down the problem (and treat the code as confidential, of course). These kinds of "impossible" results drive me nuts.

Since I only have two table views in my program the "Invalid table view" is never called. The first table view gameScoresTableView works perfectly. The playerManagementTableView does not. I do not create the table views progammatically. I use IB. I do not use bindings. My delegates are set correctly and are the same for both table views. I don't know enough about programming nor am I arrogant enough to think that there is something wrong with NSTableView. I have always thought the error was in my code. That is precisely why I asked for help. I couldn't seem to figure out what to do next. I have learned more about table views so I appreciate all the help. However it still does not work. I am going to try removing infrastructure and see if I can find the problem. Any other suggestions would be welcome. If I figure it out I will let you know. Meanwhile I am going to shine that streetlight on the bottle of beer on my desk. Maybe the solution is in there.

If it is, let us know. That would be a welcome breakthrough in computer science. :)

--Andy


_______________________________________________

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