Re: TableView displaying a zillion empty rows
Re: TableView displaying a zillion empty rows
- Subject: Re: TableView displaying a zillion empty rows
- From: Graham Cox <email@hidden>
- Date: Tue, 7 Jul 2009 13:37:41 +1000
On 07/07/2009, at 1:20 PM, Brian Hughes wrote:
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.
Bear in mind that only your data source actually sets the number of
rows. The number of rows apparently visible in IB is just how it is
displayed - there are 0 rows, not 9.
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, it has 0.
No vertical scroll to see the other 13 rows of data. Now the
tableView is behaving as if I have zero rows.
Because it does have 0 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.
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
_______________________________________________
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