RE: TableView displaying a zillion empty rows
RE: TableView displaying a zillion empty rows
- Subject: RE: TableView displaying a zillion empty rows
- From: Brian Hughes <email@hidden>
- Date: Tue, 7 Jul 2009 12:35:25 -0400
- Importance: Normal
>> 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.
>
> But you are only logging the case where it does return 22, so what
> would you expect? Instead, try moving the NSLog to log the *actual*
> return value just before you return it. I bet you will see plenty of
> 0s going out.
>
>> 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?
>
> Because clearly there are two main pathways through this code but
> you're only logging one of them. The other pathway is what's causing
> the problem but isn't being logged, so you are not "seeing" its effects.
>
> Also, in the debugger you can set a conditional breakpoint at the last
> line on returnValue == 0. When it breaks, look at <aTableView> - it
> will be something other than the two you're expecting. Debug
> accordingly.
>
> --Graham
>
>
Hi Graham,
Thanks for your help. I put an NSLog for returnValue on the line before return. I also put a conditional breakpoint on return to break if returnValue == 0. The NSLog confirmed that returnValue was indeed set to 22. The conditional breakpoint did not break yet my tableView still responds as if returnValue = 0. Just to make certain that I didn't screw up my conditional breakpoint I reset it to break if returnValue =22. It did break. Maddening!
As I debug I can clearly see that the program is not going through the other path. It is definitely traveling through the path that I am logging. Everything says that returnValue is 22 except the actual tableView. By the way when the program does use the other path everything works fine. So there is something about my code in here:
- (int) numberOfRowsInTableView: (NSTableView *)aTableView{ unsigned int returnValue = 0; if (aTableView == gameScoresTableView) //This works as expected { if (currentIndex_>= 0) { LNPlayer *currentPlayer = [playersArray objectAtIndex: currentIndex_]; NSMutableArray *tempGameRecordsArray = [NSMutableArray arrayWithArray: [currentPlayer gameRecordsArray]]; returnValue = [tempGameRecordsArray count]; NSLog (@"returnValue = %d", returnValue); //NSLog prints>> returnValue = 22; } else { NSBeep (); NSLog (@"ERROR in LNAppController -- numberOfRowsInTableView:"); return 0; } } 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 NSLog (@"returnValue = %d", returnValue); //NSLog prints>> returnValue = 22; } NSLog (@"returnValue = %d", returnValue); //NSLog prints>> returnValue = 22; return returnValue; //Conditional breakpoint set to returnValue == 0 does not break. But a conditional breakpoint set to returnValue == 22 does break!}
that is wrong but I can't figure out what it is.
Also if on the first line I don't initialize returnValue to 0 I get my zillion rows. The NSLog just before return still says returnValue = 22.
Brian
_________________________________________________________________
Insert movie times and more without leaving HotmailĀ®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_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