search

Home  >  Q&A  >  body text

ios - why use the "autorelesspool" to define a macro ?

大家讲道理大家讲道理2772 days ago687

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:01:29

    The purpose of defining a macro like this is to add an @ symbol when using it, because the usage of autoreleaasepool is like this:

    @autoreleasepool {
    }

    So using this trick when defining macros will allow you to use it like this when using macros

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

    As for the redundant @autoreleasepool {}@try {} @finally {}code introduced by the macro definition, it will be optimized away by the compiler because it does nothing, so it will not have an impact on the final generated code.

    reply
    0
  • Cancelreply