庫(kù)克剛剛開(kāi)完發(fā)布會(huì)入桂,早晨就手欠的更新了手機(jī)系統(tǒng),XCode也不得已的更新到最新的菠赚,以前的代碼報(bào)出各種cannot create __weak reference in file
的錯(cuò)誤脑豹,糾結(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 out 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請(qǐng)注意下面的問(wèn)題衡查。
__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ǔ)充