【发布时间】:2015-01-31 14:03:14
【问题描述】:
我正面临一个强大的自动释放问题:
我正在使用一个具有强大 NSProgress 的对象来管理一些文件下载。
对于下载,我使用来自 AFNetworking 的downloadtaskwithrequest。
我的问题是这种方法采用NSProgress * __autoreleasing *,这与我强大的 NSProgress 不兼容:
这是我拥有它的 NSProgress 的对象:
@interface MyDocument ()
@property(nonatomic, strong) NSProgress *progress;
@end
@implementation MyDocument ()
-(void)download
{
[myApiClient downloadFileWithUrl:_url progress:_progress]
}
@end
这是处理下载的 SessionManager:
-(void)downloadFileFromUrl:(NSString*)url progress:(NSProgress * __strong *)progress
{
NSURLSessionDownloadTask *downloadTask = [self downloadTaskWithRequest:request
progress:progress
destination:^NSURL *(NSURL *targetPath, NSURLResponse *response)
{ ... }
completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error)
{ ... }];
}
这是与progress:progress 行有关的错误:
Passing address of non-local object to __autoreleasing parameter for write-back
【问题讨论】:
标签: ios automatic-ref-counting afnetworking-2