Automatic ref counting 更新到iOS 6.1后出现ARC保留周期
更新到iOS 6.1后,我在AFImageRequestOperation.m和AFHTTPClient.m中从AFNetworking framework中得到以下警告: 在此块中强烈捕获“操作”可能会导致 保留周期 基于此,我可以通过使用_弱变量来修正ARC中的保留循环。它还说 块将由捕获的对象保留 有人知道如何解决这个问题吗Automatic ref counting 更新到iOS 6.1后出现ARC保留周期,automatic-ref-counting,afnetworking,ios6.1,Automatic Ref Counting,Afnetworking,Ios6.1,更新到iOS 6.1后,我在AFImageRequestOperation.m和AFHTTPClient.m中从AFNetworking framework中得到以下警告: 在此块中强烈捕获“操作”可能会导致 保留周期 基于此,我可以通过使用_弱变量来修正ARC中的保留循环。它还说 块将由捕获的对象保留 有人知道如何解决这个问题吗 谢谢。我们很幸运,XCode 4.6显示了一个避免此问题的警告 它可以通过提供弱参考来解决 AFImageRequestOperation *requestOpera
谢谢。我们很幸运,XCode 4.6显示了一个避免此问题的警告 它可以通过提供弱参考来解决
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
**__weak AFImageRequestOperation *tempRequestOperation = requestOperation;**
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) {
UIImage *image = responseObject;
if (imageProcessingBlock) {
dispatch_async(image_request_operation_processing_queue(), ^(void) {
UIImage *processedImage = imageProcessingBlock(image);
dispatch_async(**tempRequestOperation**.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) {
success(operation.request, operation.response, processedImage);
});
});
} else {
success(operation.request, operation.response, image);
}
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (failure) {
failure(operation.request, operation.response, error);
}
}];
好的,问题就在这里。我一直在从GitHub下载,现在我尝试下载AFNetworking(版本1.1.0),它不再向我显示警告 我不知道为什么我下载时最新的提交没有包含在主分支中,但很明显,它们已经解决了这些块中的强引用警告
始终检查以查看最新发布的版本或同步GitHub的最新提交:)(在我的iOS 6.0应用程序中没有显示任何内容,但Xcode 4.6刚刚启动了这些应用程序)我相信这在AFNetworking 1.1中得到了修复。很明显,我下载了1.1.0,警告消失了。我正在下载没有最新提交的主分支。谢谢基思。嗨,桑妮,我也做了同样的事,但警告仍然存在。我甚至下载了最新的AFNetworking框架和所有新提交,因为我被告知新提交解决了这些问题,但警告仍然存在。警告如下:AFHTTPCliend.m行#564 NSMutableArray*mutableOperations=[NSMutableArray];和AFImageRequestOperation.m行#85 dispatch_async(operation.successCallbackQueue?:dispatch_get_main_queue(),^(void){success(operation.request,operation.response,processedImage);};顺便说一句,我的应用程序没有崩溃或出现任何问题。我实现了上述解决方案,它对我有效。因此,我们是否必须下载我提供的最新版本或解决方案才能正常工作。