我正在重复使用surl,所以它好像会泄漏。但乐器不显示链接。我不能理解如何在不创建垃圾字符串的情况下重用它。为什么不是这个目标-c IOS代码泄漏?
NSString *rcode = @"DDD";
NSString *surl = [NSString stringWithFormat: @"http://www.myweather.com/%@_%@.png", rcode, @"7"];
NSURL *url = [NSURL URLWithString: surl];
UIImage *image7 = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
surl = [NSString stringWithFormat: @"http://www.myweather.com/%@_%@.png", rrcode, @"6"];
url = [NSURL URLWithString: surl];
UIImage *image6 = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
surl = [NSString stringWithFormat: @"http://www.myweather.com/%@_%@.png", rrcode, @"5"];
url = [NSURL URLWithString: surl];
UIImage *image5 = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
ObjC现在有不错的GC吗? – cHao 2011-12-30 04:19:48
@cHao Objective C for Mac OS X开发可以使用GC。对于iOS,没有GC。但是在iOS 5 sdk中,他们添加了[ARC](http://clang.llvm.org/docs/AutomaticReferenceCounting.html) – 2011-12-30 04:31:50