问题
I been trying this in my code and it doesn´t work:
NSArray *paths = [aUITableView indexPathsForVisibleRows];
An empty NSArray is returned. But if I do this in the previous line it works fine....is this a framework bug?
NSArray *cells = [aUITableView visibleCells];
NSArray *paths = [aUITableView indexPathsForVisibleRows];
The thing is I don`t really need the cells array. So I´m getting a warning for the unused variable....and I don´t like warnings in my code. jeje.
回答1:
It looks like a bug – you may want to report it.
If unused variable is a problem, then don't create unused variable! :)
Instead of:
NSArray *cells = [aUITableView visibleCells];
write:
[aUITableView visibleCells]; // don't remove, workaround for a bug <link here>
回答2:
This bug is still occurring in iOS 4.2. You can fix it without a warning by simply calling [tableView visibleCells];
and not assigning the result of the call to a variable. Just because a method has a return value, you don't need to pay attention to it. I'm filing a bug report with Apple.
来源:https://stackoverflow.com/questions/1126237/possible-bug