cellForRowAtIndexPath 中的内存泄漏:
我想在给定索引路径的情况下获取对相关单元格的引用以删除复选标记。我以为我可以使用 cellForRowAtIndexPath 为此,但我收到消息:
只是泄漏
__NSAutoreleaseNoPool(): Object 0x685a600 of class UITableView autoreleased with no pool in place -即使对于像这样的简单行也
[self.tableView cellForRowAtIndexPath:indexPath];
:所以,这不仅返回一个指向单元格的指针,对吗?也许我误解了这个方法的用途。是否可以简单地获取对单元格的引用来更改accessoryView? 谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误:
_NSAutoreleaseNoPool()
通常与此相关 - 没有适当的自动释放池。 Autoreleasepools 是基于线程的,因此如果您在后台或另一个线程上执行此操作(很难从这段小代码中看出),您需要在该线程中创建一个 NSAutoreleasPool 并在执行完成后释放它。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.