cellForRowAtIndexPath中的内存泄漏: [英] Memory leak in cellForRowAtIndexPath:

查看:327
本文介绍了cellForRowAtIndexPath中的内存泄漏:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望,在给定indexPath的情况下,获取对相关单元格的引用以删除复选标记。我以为我可以使用cellForRowAtIndexPath,但是我收到消息:

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():类UITableView的对象0x685a600自动释放,没有池到位 - 只是泄漏

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

即使是这样的简单行:

[self.tableView cellForRowAtIndexPath:indexPath];

所以,这不仅仅是返回指向单元格的指针,对吧?也许我误解了这种方法的用途。是否可以简单地获取对单元格的引用来更改accessoryView?
谢谢!

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!

推荐答案

此错误: _NSAutoreleaseNoPool()通常与此完全相关 - 没有自动发布池。 Autoreleasepool是基于线程的,所以如果你在后台或另一个线程上执行它(很难从这个小代码中解释),你需要在该线程中创建一个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.

这篇关于cellForRowAtIndexPath中的内存泄漏:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆