【问题标题】:Default property attribute in iOSiOS 中的默认属性
【发布时间】:2015-08-27 02:55:52
【问题描述】:

我的接口文件中有以下提到的属性

@property NSString *stringObject;
@property NSMutableString *anotherStringObject;
@property NSArray *array;
@property NSMutableArray *anotherarray;
@property NSNumber *number;
@property NSDictionary *dictionary;
@property NSMutableDictionary *anotherDictionary;

@property NSInteger myInteger;
@property int intValue;
@property BOOL boolValue;
@property CGFloat floatValue;

由于我在这里没有明确提到任何属性,所以我想知道编译器在这段代码中添加的默认属性是什么。

注意:我已经阅读了苹果指南,默认情况下只有我得到的信息是atomicstrong。我想知道与它们一起添加的其他属性。

【问题讨论】:

  • 默认/隐式值为 atomic、readwrite 和 assign。
  • 为标量赋值,为对象赋值。
  • ARC 变强了
  • @SandeepAgrawal,不适用于标量。
  • @SandeepAgrawal,请参阅我的第一条评论。

标签: ios objective-c properties attributes


【解决方案1】:

如果你没有提到你想要的属性,那么它将是:

对于对象(NSObject、NSNumber 等)==> 读写/原子/强 对于标量(NSIneger、BOOL 等)==> 读写/原子/分配

【讨论】:

  • 所以如果我有一个块作为属性,它会是原子和复制吗?
猜你喜欢
  • 2010-09-22
  • 1970-01-01
  • 1970-01-01
  • 2012-08-07
  • 1970-01-01
  • 1970-01-01
  • 2010-10-16
  • 1970-01-01
  • 2012-09-27
相关资源
最近更新 更多