2013-02-02 50 views
3

更新到iOS 6.1後後,我從AFNetworking框架在獲得和AFImageRequestOperation.m這AFHTTPClient.m警告:ARC保留週期出現更新至iOS 6.1

捕獲「操作」在此塊強烈很可能導致 保留週期

基於this answer,我可以通過使用__weak變量修復ARC一個保留週期。它也說

塊將被拍攝對象保持

有誰知道如何解決這個問題?

謝謝。

+1

我相信這是固定在AFNetworking 1.1 –

+1

準確地說,我下載了1.1.0並且警告消失了。我正在下載沒有最新提交的Master分支。謝謝基思。 – Maziyar

回答

0

確定這裏是問題。我一直在從GitHub下載Master branch,現在我嘗試下載AFNetworking from here(版本1.1.0),它不再顯示警告。

我不是爲什麼當我下載時最新的提交沒有被包含在master分支中,但顯然他們已經解決了這些強大的引用,而且在前面的塊警告中。

經常檢查website看到最新發布的版本或同步的最新從GitHub提交:)(這不是顯示任何在我的iOS 6.0版本,但Xcode的4.6只是把他們帶到了)

4

我們很幸運的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); 
    } 
}]; 
+0

嗨,陽光,我做了完全一樣的事情,但警告仍然存在。我甚至用所有新提交下載了最新的AFNetworking框架,因爲我被告知新提交可以解決這些問題,但警告仍然存在。警告在這裏: AFHTTPCliend.m行#564 NSMutableArray * mutableOperations = [NSMutableArray array]; 和AFImageRequestOperation.m行#85 dispatch_async(operation.successCallbackQueue:dispatch_get_main_queue(),^(無效){ 成功(operation.request,operation.response,processedImage); });順便說一下,我的應用程序沒有崩潰或顯示任何問題。 – Maziyar

+0

我實現了上述解決方案,它爲我工作。所以我們必須下載我提供的最新版本或解決方案。 – Harini