开发者

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

开发者 https://www.devze.com 2023-02-04 10:11 出处:网络
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 some

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 :-)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消