【发布时间】:2026-01-03 18:25:01
【问题描述】:
在使用 ARC for iOS 时,以下有什么区别吗?
@property (strong, nonatomic) NSObject *someProperty;
...
@synthesize someProperty;
//and then in the init method, either:
self.someProperty = aProperty;
//or
someProperty = aProperty;
我知道,如果没有 ARC,self.someProperty 实际上会调用合成的 setter 方法,该方法会向对象发送 retain 消息。但是现在有了 ARC,我是否使用点符号来设置这样的属性?
更一般地说,ARC 真的意味着我根本不必担心引用计数吗?或者在某些情况下我编写代码的方式可能会导致 ARC 出错?
【问题讨论】:
标签: ios cocoa-touch memory-management automatic-ref-counting