ios - 声明是否确实需要Objective-C属性吗?

标签 ios objective-c memory-management declared-property

到目前为止,我的理解是(保留)增加了属性的引用计数,并且本质上与(strong)完全相同。由于所有属性均默认设置为保留(除非另有说明),因此完全需要添加(强):

@property(nonatomic, strong) NSString *name;

是相同的:
@property(nonatomic) NSString *name;

上面的两个都一样吧?

最佳答案

自引入ARC以来,默认情况下设置为“strong”,“atomic”和“readwrite”。

这些属性是等效的:

@property NSArray *name;
@property (strong, atomic, readwrite) NSArray *name;

资料来源:http://useyourloaf.com/blog/default-property-attributes-with-arc.html

关于ios - 声明是否确实需要Objective-C属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33918798/

相关文章:

ios - 自动化测试ABAddressBook和ALAssetsLibrary请求访问

ios - 后台播放音乐 : AVAudioSessionInterruptionNotification not fired

ios - Sprite Kit检测触摸位置

android - 使用 Handler 可能发生内存泄漏?

c - 设置堆页的 PG_Referenced 位的内核函数

ios - 无法在 Swift 中使用 NSPredicate 查询日期

objective-c - 使用 SMJobBless() 编写特权帮助工具

React Native 中的 iOS websocket 内存问题

iphone - 如何按字母顺序对带有字典对象的 NSArray 进行排序?

在 C 中调用 free() 会失败吗?