Should I declare it as
(#1) ClassName * __block variableName
or
(#2) __block ClassName * variableName
?
I seen a lot of code uses format #2, Including Apple's Blocks Programming Topics .
But recently I found Apple's " Transitioning to ARC Release Notes " says:
You should decorate variables correctly. When using qualifiers in an object variable declaration, the correct format is:
ClassName * qualifier variableName;
for example:
MyClass * __weak myWeakReference;
Other variants are technically incorrect but are “forgiven” by the compiler. To understand the issue, see http://cdecl.org/ .
So I'm confused, Which format should I use in the future?
They are essentially the same. I personally prefer placing __block
at the beginning since it's more important than the variable's type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.