Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 250
BeachRunnerFred Avatar asked Dec 19 '12 19:12

BeachRunnerFred


1 Answers

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.

like image 157
BJ Homer Avatar answered Oct 14 '22 12:10

BJ Homer