以前的問題实幕,XCode也不得已的更新到最新的飞崖,以前的代碼報出各種cannot create __weak reference in file
的錯誤,糾結(jié)數(shù)日氮帐,現(xiàn)終總結(jié)出以下方案:
在網(wǎng)上看到的蘋果官方回復(fù):
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 設(shè)置為YES
快速查找輸入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.
如有其它方案再加以補(bǔ)充