简体   繁体   English

在非ARC iOS Objective-C代码中使用__weak有什么缺点吗?

[英]Is there any downside to using __weak in non-ARC iOS Objective-C code?

I'm writing iOS Objective-C code sans ARC. 我正在编写没有ARC的iOS Objective-C代码。 I prefer 我更喜欢

__weak MyClass *myWeakIVar;

to, eg

MyClass *myWeakIvar; // weak

Not only does it read better to me, but if I ever use this code on a garbage-collected platform, etc., I get the benefits of the __weak directive. 它不仅让我读起来更好,而且,如果我曾经在垃圾收集平台等上使用此代码,我将获得__weak指令的好处。 Are there any downsides to this? 这有什么缺点吗? Put another way, is it presently equivalent (again, w/o ARC) to a noop on iOS? 换句话说,它当前是否等同于iOS上的noop(再次没有ARC)?

根据此线程 ,如果禁用了ARC, __weak在iOS上不执行任何操作。

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

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