[英]Retain cycle in AFNetworking success block
通常,Xcode在塊中使用強引用時會顯示警告(保留周期)。 但是,我不明白為什么它沒有用這個AFNetworking
示例顯示它。
UIImageView *imageView;
AFHTTPRequestOperation *operation = [apiQueryManager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, NSData *responseObject) {
UIImage *image = [UIImage imageWithData:responseObject];
imageView.image =image; // <--- using strong ref to imageView ?
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"ERROR: %@", error);
}];
[apiQueryManager enqueueHTTPRequestOperation:operation];
這里有保留周期嗎?
要由於imageView
而具有保留周期, imageView
需要對使用它的塊具有強引用。 不是這種情況。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.