Hi I am getting a reported leak from Instrument with the following code.
dispatch_async(requestQueue, ^{
NSURL *urlRequest = [NSURL URLWithString:url];
NSError *error = nil;
NSData *imageData = [NSData dataWithContentsOfURL:urlRequest
options:0
error:&error];
if (error != nil)
{
NSLog(@"%@ %@", [error localizedDescription], [error localizedFailureReason]);
[[[[UIAlertView alloc] initWithTitle:[error localizedDescription]
message:[error localizedFailureReason]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil] autorelease] show];
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
image = [UIImage imageWithData:imageData];
if (delegate != nil && [delegate respondsToSelector:@selector(imageRequestDone:)])
{
[delegate imageRequestDone:image];
}
});
});
Leaks reports that my image = [UIImage imageWithData:imageData] leaks, any ideas why? Do I need to a NSAutoreleasePool for the autoreleased UIImage object?
Btw, If its matter, I declared __block UIImage *image = nil; above because I check for the image in an ImageCache before entering the code above.
You haven't released your queue:
dispatch_release(requestQueue);