Memory leak in cellForRowAtIndexPath:

这一生的挚爱 提交于 2019-12-08 11:56:40

问题


I would like, given the indexPath, to get a reference to the related cell to remove the checkmark. I thought I could use the cellForRowAtIndexPath for this, but I get the message:

__NSAutoreleaseNoPool(): Object 0x685a600 of class UITableView autoreleased with no pool in place - just leaking

even for a simple line like this:

[self.tableView cellForRowAtIndexPath:indexPath];

So, this is not only returning a pointer to a cell, right? Maybe I'm misunderstanding what this method is for. Is it possible to simply get a reference to a cell to change the accessoryView? Thanks!


回答1:


This error: _NSAutoreleaseNoPool() is generally related to exactly this - not having an Auto release pool in place. Autoreleasepools are thread-based, so if you are executing this in the background or on another thread (hard to tell from this little code) you'll need to create an NSAutoreleasPool in that thread and release it after you're done with your execution.



来源:https://stackoverflow.com/questions/4359905/memory-leak-in-cellforrowatindexpath

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