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

项目中出现一堆相同的警告:Block implicitly retains ‘self’; explicitly mention ‘self’ to indicate this is intended behavior,其中的意思是block中使用了self的实例变量 _xxx ,因此block会隐式的retain住self。Xcode认为这可能会给开发者造成困惑,或者因此而因袭循环引用,所以警告我们要显示的在block中使用self,以达到block显示retain住self的目的。

解决方案:

  • 方案一:
按照Xcode提示,改成self->_xxx
  • 方案二:
Building Settings->CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF 设置为NO

你可能感兴趣的:(iOS-Block implicitly retains ‘self’; explicitly mention ‘self’ to indicate this is intended behavior)