ARC Lifetime Qualifiers


#1

Hello,

I see a lot of sample code for declaring variables with ARC lifetime qualifiers written as follows:

However according to Apple’s Transitioning to ARC release notes:

[quote]You should decorate variables correctly. When using qualifiers in an object variable declaration, the correct format is:

ClassName * qualifier variableName;
[/quote]

For the example above that would change the declaration to:

They also say:

The first example being such a variation.

The question is whether this is simply a stylistic issue and it really doesn’t matter or if there is some subtle difference that affects correctness between the two?

For example with regard to the “volatile” qualifier there is a significant difference that can lead to incorrect results between

and

Thanks,
Rob Saccone


#2

That ARC guide is outdated. Basically, when we chose where to put the qualifiers we thought about what made sense (easier to edit, easier to notice) and then we looked at what Apple actually does in their own code. For example, if you create an outlet by dragging from a XIB into a source file and choose weak, the __weak goes on the front.