美文网首页
2019-01-30

2019-01-30

作者: myleirenbaobao | 来源:发表于2019-01-30 19:00 被阅读0次

    (```)
    __weak typeof(self) weakSelf = self;
    self.block = ^{
    __strong typeof(self) strongSelf = weakSelf;
    strongSelf.doSomething();

        __weak typeof(self) weakSelf2 = strongSelf;
        strongSelf.block = ^{
            __strong typeof(self) strongSelf2 = weakSelf2;
            strongSelf2.doSomething();
        }
    }
    
    __weak typeof(self) weakSelf = self;
    self.block = ^{
        __strong typeof(self) strongSelf = weakSelf;
        strongSelf.doSomething();
    
        strongSelf.block = ^{
            __strong typeof(self) strongSelf2 = weakSelf;
            strongSelf2.doSomething();
        }
    }
    
    
    @weakify(self)
    self.blockA = ^{
        @strongify(self)
        [self doSomething];
        //不加weakify
        self.blockB = ^{
            @strongify(self)
            [self doSomething];
        };
    };
    
    @autoreleasepool {} 
    __attribute__((objc_ownership(weak))) __typeof__(self) self_weak_ = (self);
    self.blockA = ^{
        @autoreleasepool {}
         __attribute__((objc_ownership(strong))) __typeof__(self) self = self_weak_;
       [self doSomething];
        self.blockB = ^{
            @autoreleasepool {}
           __attribute__((objc_ownership(strong))) __typeof__(self) self = self_weak_;
           [self doSomething];
        };
    };
    
    
    @weakify(self)
    self.blockA = ^{
        @strongify(self)
        [self doSomething];
        //加weakify
        @weakify(self)
        self.blockB = ^{
            @strongify(self)
            [self doSomething];
        };
    };
    
    @autoreleasepool {} 
     __attribute__((objc_ownership(weak))) __typeof__(self) self_weak_ = (self);
    self.blockA = ^{
        @autoreleasepool {}
        [self doSomething];
        @autoreleasepool {} __attribute__((objc_ownership(weak))) __typeof__(self) self_weak_ = (self);
        self.blockB = ^{
            @autoreleasepool {}
             __attribute__((objc_ownership(strong))) __typeof__(self) self = self_weak_;
             [self doSomething];
        };
    };
    

    (```)

    相关文章

      网友评论

          本文标题:2019-01-30

          本文链接:https://www.haomeiwen.com/subject/aoicsqtx.html