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

阅读 2.7k
1 个回答

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

@autoreleasepool {
}

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

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

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题