chance
chance

Reputation: 18

Instruments-Xcode-Leaks=> [UIImage imageWithData:]

New to using Instruments, but figured it would be good to help the performace of my application I am developing. I am getting Error leaks on the following command, and was wondering if it might be something I am doing wrong, or can I actually deallocate this.

BASICS - a UITableView is loaded - using JSONDeserializer the data is parsed and pushed into a NSDictionary. the text labels have no leaks, it's my UIImage that is having the leak. (Each tablecell has 1 image, that is loaded through JSONDeserizer that has a valid link (http) for the picture, and the picture is downloaded and then displayed in that specific cell

Here is the coding....

cell.myImageView.image = [[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:[dict objectForKey:@"picture"]]]] retain];

any help would greatly be appreciated... thanks :-)

Upvotes: 0

Views: 867

Answers (1)

Eimantas
Eimantas

Reputation: 49354

You don't need to retain the object returned with imageWithData since the assignment does the retention for you.

Instruments are showing you leak because of that extra retain count increment. Remove the retain and all should be fine.

Upvotes: 2

Related Questions