Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use commercial at sign in Objective-C macro?

How can I use commercial at sign in Objective-C macro?

I know it is not recommended, but seems it is possible somehow? Since libextobjc provides @weakify, @strongify, etc...

like image 758
Nik Avatar asked Sep 03 '13 18:09

Nik


1 Answers

libextobjc uses preprocessor trickery to make you think it's an @command.

#define weakify(...) \
    try {} @finally {} \
    metamacro_foreach_cxt(ext_weakify_,, __weak, __VA_ARGS__)

Note the missing @ on the try. So @weakify expands into @try {} @finally {} [injected code].

You could use the same trick, but I suggest you stick with plain macros.

like image 70
Kevin Avatar answered Nov 15 '22 11:11

Kevin