starwar2012 2013-02-25 03:30 采纳率: 0%
浏览 1802

在ARC的@property使用

/ .h
@property ( strong, nonatomic ) NSString *note;

// .m
@synthesize note = _note;

- ( id ) initWithNote: ( NSString * )note {

    self = [ super init ];
    if ( self ) {
        _note = note;   // _note is just a instance variable.
        self.note = note;   // 'self.note = note;' is using setter method.
        return self;
    }
    return nil;
}

@property ( strong, nonatomic ) NSString *note; 影响setter和getter方法,默认情况下,ARC中变量是 __strong类型。

那么, _note = note;self.note = note; 的区别在哪里?除了strong,非ARC的retain也会有影响。

  • 写回答

1条回答

  • shiter 人工智能领域优质创作者 2015-01-14 07:16
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?