xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code
2023-09-11 14:15:06 时间
xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code
解决方法:
方法一:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:Api]]; __block ASIHTTPRequest *brRequest = request; [request setCompletionBlock:^{ id json = [NSJSONSerialization JSONObjectWithData:[brRequest responseData] options:0 error:Nil]; //NSLog(@"%@",json); NSLog(@"completed"); }]; [request setFailedBlock:^{ NSLog(@"%@",[brRequest error]); }]; [request startAsynchronous];
方法2:
// //方式二 // __weak ASIHTTPRequest *werRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:api]]; // [werRequest setCompletionBlock:^{ // id json = [NSJSONSerialization JSONObjectWithData:[werRequest responseData] options:0 error:Nil]; // NSLog(@"%@",json); // // }]; // // [werRequest setFailedBlock:^{ // NSLog(@"%@",[werRequest error]); // }]; // // [werRequest startAsynchronous];
相关文章
- Visual Studio Code(VS code)你们都在用吗?或许你们需要看一下这篇博文 Asp.Net Core + SignalR 实现实时通信 Net Core 下 Newtonsoft.Json 转换字符串 null 替换成string.Empty
- XCODE插件 之 Code Pilot 无鼠标化
- XCODE打包安装包步骤
- 《Xcode实战开发》——1.1节下载
- 《Xcode实战开发》——2.6节编辑器区域
- Xcode 清理存储空间
- SwiftUI AI教程之 在 Xcode 中为 RealityKit SwiftUI 项目设置 MVVM
- SwiftUI Xcode 13 Product目录消失 如何获取app路径
- Xcode 12.2 Beta Release 更新文档
- 在Xcode中使用Git进行源码版本控制
- 报错 - Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lex failed with exit code 1
- Mac/Xcode - 开发技巧快捷键