简体   繁体   English

__weak UIDataType * weakSelf和UIDataType __weak * weakSelf之间的区别?

[英]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! 提前感谢您的智慧!

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只能应用于指向对象的指针类型,因此编译器会认识到只有一个含义对以下所有内容都有意义:

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

The same applies to the other ownership qualifiers ( __strong , __autoreleasing , etc.) 这同样适用于其他所有权限定符( __strong__autoreleasing等)

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 . 如果您习惯阅读编程语言的技术规范,可以在此处阅读更多相关信息: http//clang.llvm.org/docs/AutomaticReferenceCounting.html#spelling

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM