mirror of
https://github.com/NohamR/knowledge-kit.git
synced 2026-05-25 04:17:17 +00:00
docs: 内容
This commit is contained in:
21
Chapter1 - iOS/1.89.md
Normal file
21
Chapter1 - iOS/1.89.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# block 原理
|
||||
|
||||
1. 解决循环引用不应该使用 weakself,而是使用 strong-weak
|
||||
```Objective-c
|
||||
__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();
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
字节对齐:k值:8的倍数。
|
||||
|
||||
字节对齐的原因:
|
||||
Reference in New Issue
Block a user