[英]default property declaration in non-ARC project
What is the default property value if I just do the following:如果我只执行以下操作,默认属性值是多少:
@property (nonatomic) UIButton *myButton;
in a non-ARC project.在非 ARC 项目中。 Is this retain or assign?
这是保留还是分配?
Since in non-ARC projects of any size its pretty important to see exactly whats retained and assigned or copied, I would really recommend not using that default.由于在任何规模的非 ARC 项目中,查看保留、分配或复制的内容非常重要,因此我真的建议不要使用该默认值。
Its hard to read when your looking at a class with several properties that may have many other attributes such as readonly, atomic and non atomic.当您查看一个具有多个属性的类时,它很难阅读,这些属性可能具有许多其他属性,例如只读、原子和非原子。 getter= etc
吸气剂=等
Although its not perfect putting a #define in a constant header like尽管将#define 放在常量标题中并不完美,例如
#define ASSIGN nonatomic, assign
#define RETAIN nonatomic, retain
for your most common usages can make your property definitions a little more explicit so that when you eventually catch up to writing your dealloc methods its a really quick check to see what you need to release.对于您最常见的用法,可以使您的属性定义更加明确,以便当您最终赶上编写 dealloc 方法时,它可以快速检查您需要发布的内容。
Most of my property definitions looks like我的大部分属性定义看起来像
@property (ASSIGN) Foo* foo;
or或者
@property (RETAIN) Foo* foo;
Thats what I do and it keeps the noise on property definitions down and makes the code read a little easier when troubleshooting or perfecting manual memory managed apps.这就是我所做的,它降低了属性定义上的噪音,并使代码在故障排除或完善手动内存管理应用程序时更容易阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.