Ios 在成功块中保留循环

Ios 在成功块中保留循环,ios,objective-c,xcode,objective-c-blocks,retain-cycle,Ios,Objective C,Xcode,Objective C Blocks,Retain Cycle,通常,在块中使用强引用时,Xcode会显示警告(保留循环)。但是,我不明白为什么在这个AFNetworking示例中没有显示它 UIImageView *imageView; AFHTTPRequestOperation *operation = [apiQueryManager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, NSData *responseObject)

通常,在块中使用强引用时,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];
UIImageView*imageView;
AFHTTPRequestOperation*操作=[apiQueryManager HTTPRequestOperationWithRequest:请求成功:^(AFHTTPRequestOperation*操作,NSData*响应对象){
UIImage*image=[UIImage imageWithData:responseObject];

imageView.image=image;//由于
imageView
的原因,要有一个保留周期,
imageView
需要有一个对使用它的块的强引用。事实并非如此。

在您的示例中,不,如果在块中使用
操作
,则会出现一个保留周期。好的,我现在就知道了:)谢谢大家,顺便说一句这样,我认为AFNetworking将成功块的参数作为弱引用(如果我没有弄错的话),因此,@GuyKogus,就不会有保留周期了?当一个对象保留了一个保留该对象的块时,通常会发生一个保留周期(我知道,听起来很混乱).调用块时,传递到块中的参数不会保留在块对象中(是的,块是对象),因此没有保留周期。