最近兩天升級(jí)了一下Xcode 7.3 出現(xiàn)
__weak typeof(self) weakSelf = self;
無法使用的錯(cuò)誤
報(bào)錯(cuò)位置:
__weak typeof(self) weakSelf = self;
錯(cuò)誤提示:
Cannot create __weak reference in file using manual reference counting
// 不能在文件中使用手動(dòng)引用創(chuàng)建 __weak 引用,工程一般是自動(dòng)管理的,不是在非ARC模式
解決方案一
在build setting 直接在search 內(nèi)搜索 關(guān)鍵字 weak
就找到了
選中項(xiàng)目名字-> Target->Build Setting -> Apple LLVM7.1 -
Language - Objective C ->Weak References in Manual Retain Release 將其value 設(shè)置為YES,
解決方案二:
將 `__weak` 替換成 `__unsafe_unretained`
使用 `__unsafe_unretained ` 請(qǐng)注意以下問題:
注意事項(xiàng) 使用 __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.
設(shè)置完畢,重新編譯運(yùn)行。