possible bug?

[亡魂溺海] 提交于 2019-12-07 10:31:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!