File tree Expand file tree Collapse file tree 1 file changed +1
-6
lines changed Expand file tree Collapse file tree 1 file changed +1
-6
lines changed Original file line number Diff line number Diff line change 11# 如何在 Objective-C 的环境下实现 defer
22
3- > 关注仓库,及时获得更新:[ iOS-Source-Code-Analyze] ( https://github.com/draveness/iOS-Source-Code-Analyze )
4- >
5- > Follow: [ Draveness · Github] ( https://github.com/Draveness )
6-
73这篇文章会对 [ libextobjc] ( https://github.com/jspahrsummers/libextobjc ) 中的一小部分代码进行分析,也是** 如何扩展 Objective-C 语言** 系列文章的第一篇,笔者会从 libextobjc 中选择一些黑魔法进行介绍。
84
95对 Swift 稍有了解的人都知道,` defer ` 在 Swift 语言中是一个关键字;在 ` defer ` 代码块中的代码,会** 在作用域结束时执行** 。在这里,我们会使用一些神奇的方法在 Objective-C 中实现 ` defer ` 。
@@ -152,7 +148,6 @@ __strong ext_cleanupBlock_t ext_exitBlock_19 __attribute__((cleanup(ext_executeC
152148
153149libextobjc 将 ` cleanup ` 这一变量属性,很好地包装成了 ` @onExit ` ,它的实现也是比较有意思的,也激起了笔者学习 GCC 编译命令并且阅读一些文档的想法。
154150
155-
156-
151+ > Follow: [ Draveness · Github] ( https://github.com/Draveness )
157152
158153
You can’t perform that action at this time.
0 commit comments