2019-01-30

2019-01-30  本文已影响0人  myleirenbaobao

(```)
__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];
    };
};

(```)

上一篇 下一篇

猜你喜欢

热点阅读