BeachRunnerFred
BeachRunnerFred

Reputation: 18558

Difference between __weak UIDataType *weakSelf and UIDataType __weak *weakSelf?

I'm seeing two different implementations...

__weak UIDataType *weakSelf = self;

and

UIDataType __weak *weakSelf = self;

Yet they both seems to work. Is there a difference in terms of what happens under the hood?

Thanks in advance for your wisdom!

Upvotes: 6

Views: 188

Answers (1)

BJ Homer
BJ Homer

Reputation: 49034

There is no difference. Since __weak can only apply to pointer-to-object types, the compiler recognizes that there is only one meaning that makes sense for all of the following:

__weak UIDataType *weakSelf;
UIDataType __weak *weakSelf;
UIDataType * __weak weakSelf;

The same applies to the other ownership qualifiers (__strong, __autoreleasing, etc.)

If you're comfortable reading technical specifications of programming languages, you can read more about it here: http://clang.llvm.org/docs/AutomaticReferenceCounting.html#spelling.

Upvotes: 4

Related Questions