gpt4 book ai didi

ios - 在 AFNetworking 成功 block 中保留循环

转载 作者:行者123 更新时间:2023-11-28 22:22:18 25 4
gpt4 key购买 nike

通常,Xcode 在 block 中使用强引用时会显示警告(循环保留)。但是,我不明白为什么它没有在这个 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];

这里有没有retain cycle?

最佳答案

由于 imageView,要有一个保留周期,imageView 需要对使用它的 block 有一个强引用。事实并非如此。

关于ios - 在 AFNetworking 成功 block 中保留循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19998254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com