以前的问题,XCode也不得已的更新到最新的,以前的代码报出各种cannot create __weak reference in file
的错误,纠结数日,现终总结出以下方案:
在网上看到的苹果官方回复:
This issue behaves as intended based on the following: We are in the process of implementing weak references in all Objective-C language modes. Since “__weak” has historically been ignored in non-ARC (and non-GC) language modes, we’ve added this error to point o
ut places where the semantics will change in the future. Please update your bug report to let us know if this is still an issue for you.
解决方案:
解决办法一:
找到 build setting -> Apple LLVM7.1 - Language - Objective C -> Weak References in Manual Retain Release 设置为YES
快速查找输入Apple
查找apple解决办法二:
用__unsafe_unretained 代替____weak,但是如果__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.
如有其它方案再加以补充
网友评论