關(guān)于Xcode7.3報(bào)錯(cuò)cannot create __weak reference in file 解決方案

庫(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)上看到的蘋(pí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ǔ)充

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容