Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios xcode使用仪器查找内存泄漏_Ios_Objective C_Automatic Ref Counting - Fatal编程技术网

Ios xcode使用仪器查找内存泄漏

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

我有一个启用了ARC的iOS项目,我正在使用Leaks工具查找漏洞。 我在这行代码中有一个漏洞,我不明白为什么会有漏洞:

[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;

}