Search code examples
iphoneobjective-cxcode4autorelease

"of class NSURL autoreleased with no pool in place - just leaking" Help


-(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!


Solution

  • 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.