Apple tends to give examples like this:
NSError __strong *error = nil;
or
-(BOOL)performOperationWithError:(NSError * __autoreleasing *)error;
I’d find it much more readable and logical if I could do it this way:
__strong NSError *error = nil;
-(BOOL)performOperationWithError:(__autoreleasing NSError**)error;
A quick test revealed that the compiler is not complaining about my way of writing it. Am I doing it wrong anyways, or is it just fine to write it like this?
No, the position of the ownership qualifier doesn’t matter at all. Since the ownership qualifiers only have meaning for pointer-to-object types, your intention is never ambiguous. The compiler can easily figure out what your intention is no matter where you place it, so ARC does exactly that.
If you have access to the iOS Apple Developer Forums, then you can see where I asked this same question of Apple’s engineers at https://devforums.apple.com/message/458606.