首页 > why use the "autorelesspool" to define a macro ?

why use the "autorelesspool" to define a macro ?

why use the "autorelesspool" to define a macro, and what advantages do using this method have?

thanks for all you


这样定义一个宏是为了使用的时候可以加上一个@符号,因为autoreleaasepool的用法是这样的:

@autoreleasepool {
}

所以在定义宏的时候使用这个trick可以让你在使用宏的时候这样来用

@weakify(self),
@strongify(self),

至于宏定义引入的多余的@autoreleasepool {}@try {} @finally {}这种代码由于什么都没有做会被编译器给优化掉,所以并不会对最后生成的代码有影响。

【热门文章】
【热门文章】