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

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。