Quantcast
Channel: 可丁丹尼 @ 一路往前走2.0
Viewing all articles
Browse latest Browse all 79

Block implicitly retains ‘self’; explicitly mention ‘self’ to indicate this is intended behavior Insert ‘self->’

$
0
0

Block implicity retains self explicitly metion self to

當你更新Xcode 9.3以上時,開舊版本專案進行重新編譯時會發生下列情況:

Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior Insert 'self->'

新版Xcode針對CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF這問題的預設值為Yes,請查看一下你的設定是否為No

2018-05-24_16-28-20

如果你的專案是舊版本Xcode升級上來,但看到此預設值正確但無作用時,必需要做一個動作:

將設定值先改為Yes後,再重新選擇No,如此一來Xcode才會把新的值寫進去你的專案。然而這個設定值的用意就是讓你使用blocks省略在變數前面加上self->,讓程式編譯時自動幫你加上,加上這個用意是你使用block時避免此變數被release掉,讓它retain。

The post Block implicitly retains ‘self’; explicitly mention ‘self’ to indicate this is intended behavior Insert ‘self->’ appeared first on 可丁丹尼 @ 一路往前走2.0.


Viewing all articles
Browse latest Browse all 79

Trending Articles