Ios xcode使用仪器查找内存泄漏
我有一个启用了ARC的iOS项目,我正在使用Leaks工具查找漏洞。 我在这行代码中有一个漏洞,我不明白为什么会有漏洞:Ios xcode使用仪器查找内存泄漏,ios,objective-c,automatic-ref-counting,Ios,Objective C,Automatic Ref Counting,我有一个启用了ARC的iOS项目,我正在使用Leaks工具查找漏洞。 我在这行代码中有一个漏洞,我不明白为什么会有漏洞: [self.activeDownload appendData:data]; 这是该类的代码 @interface IconDownloader () @property (nonatomic, strong) NSMutableData *activeDownload; @property (nonatomic, strong) NSURLConnection *imag
[self.activeDownload appendData:data];
这是该类的代码
@interface IconDownloader ()
@property (nonatomic, strong) NSMutableData *activeDownload;
@property (nonatomic, strong) NSURLConnection *imageConnection;
@end
@implementation IconDownloader
@synthesize url = _url;
@synthesize activeDownload = _activeDownload;
@synthesize imageConnection = _imageConnection;
- (void)startDownload
{
self.activeDownload = [NSMutableData data];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
self.imageConnection = conn;
}
- (void)cancelDownload
{
[self.imageConnection cancel];
self.imageConnection = nil;
self.activeDownload = nil;
self.completionHandler = nil;
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[self.activeDownload appendData:data]; // leak
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
self.activeDownload = nil;
self.imageConnection = nil;
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if (self.completionHandler) {
self.completionHandler(self.activeDownload);
}
self.imageConnection = nil;
}