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

后端 未结 5 1757
无人及你
无人及你 2020-12-04 17:48

Given the following:

- (void) someMethod
{
    dispatch_async(dispatch_get_main_queue(), ^{
        myTimer = [NSTimer scheduledTimerWithTimeInterval: 60
            


        
5条回答
  •  长情又很酷
    2020-12-04 18:06

    Details

    Xcode: 9.2, 10.2, 11.0 (11A420a)

    Warnings in Objective-C Pods

    I have swift project. Warning Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior appears when I use Objective-C pods:

    • Bolts
    • FBSDKCoreKit
    • FBSDKLoginKit

    Solution 1 (manual)

    CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO
    

    Solution 2 (automatic)

    Add to the end of your Podfile:

    post_install do |installer|
          installer.pods_project.targets.each do |target|
               target.build_configurations.each do |config|
                    config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = 'NO'
               end
          end
     end
    

    Results

提交回复
热议问题