Files
knowledge-kit/Chapter1 - iOS/1.89.md
杭城小刘 e89fe0ca1c docs: 内容
2020-11-08 15:51:47 +08:00

571 B
Raw Blame History

block 原理

  1. 解决循环引用不应该使用 weakself而是使用 strong-weak
__weak typeof(self) Weakself = self;
self.block = ^ {
    __strong typeof(Weakself) Strongself = Weakself;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^ {
        NSLog(@"%@", Strongself.name);
    });
};
self.block();

![image-20200810214301251](/Users/lbp/Library/Application Support/typora-user-images/image-20200810214301251.png)

字节对齐k值8的倍数。

字节对齐的原因: