__weak 报错

来源:互联网 发布:linux 查看服务器配置 编辑:程序博客网 时间:2024/06/05 10:22

解决方案一

在build setting 直接在search 内搜索 关键字 weak 就找到了

选中项目名字-> Target->Build Setting -> Apple LLVM7.1 - Language - Objective C ->Weak References in Manual Retain Release   将其value 设置为YES,

解决方案二:

将  `__weak`  替换成 `__unsafe_unretained`  使用 `__unsafe_unretained ` 请注意以下问题:

注意事项 使用 __unsafe_unretained 注意以下问题:

__unsafe_unretained specifies a reference that does not keep the referenced object alive and is not set to nil when there are no strong references to the object. If the object it references is deallocated, the pointer is left dangling.

设置完毕,重新编译运行。



作者:Raybon_lee
链接:http://www.jianshu.com/p/2a93f58fd18f
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。