“NSURL 类自动释放,没有池 - 只是泄漏”帮助
-(void)setIT:(customOfferCell *)curr {
NSAutoreleasePool *imagePool = [ [ NSAutoreleasePool alloc ] init ];
NSURL *url = [[NSURL URLWithString:imageURL]autorelease];
NSData *imageData = [[NSData dataWithContentsOfURL:url] autorelease];
curr.offerImage.image = [[UIImage imageWithData:imageData]autorelease];
[imagePool drain];
}
嗨,我有标题错误,程序运行良好,但泄漏的数量让我担心,我调查了导致它的原因,因为这个方法是在新线程上调用的:
[NSThread detachNewThreadSelector: @selector(setIT:) toTarget:self withObject:cell];
我需要创建一个自动释放池并自动释放对象。调用上面的方法将图像加载到我的自定义 UITableViewCell 上。当我运行这个时,我在甚至没有运行的代表上收到奇怪的错误。有人可以帮忙吗?
谢谢!
-(void)setIT:(customOfferCell *)curr {
NSAutoreleasePool *imagePool = [ [ NSAutoreleasePool alloc ] init ];
NSURL *url = [[NSURL URLWithString:imageURL]autorelease];
NSData *imageData = [[NSData dataWithContentsOfURL:url] autorelease];
curr.offerImage.image = [[UIImage imageWithData:imageData]autorelease];
[imagePool drain];
}
Hi I had the title error and the program ran fine, but the number of leaks concerned me, I looked into what was causing it and because this method is called on a new thread:
[NSThread detachNewThreadSelector: @selector(setIT:) toTarget:self withObject:cell];
I need to create an autorelease pool and autorelease the objects. The above method is called to load an image onto my custom UITableViewCell. When I run this I get weird errors on delegates that aren't even running. Can anyone help?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用返回自动释放值的工厂方法创建对象,然后自动释放它们!但这应该会导致过度释放问题,而不是泄漏。
You are creating your objects with factory methods that return autorelease values, and then you are autoreleasing them! That should lead to an over-release problem, not a leak, though.