开发者

Under what circumstances should we set properties for int / BOOL / float and etc

开发者 https://www.devze.com 2023-01-14 03:57 出处:网络
I just put int anInteger in the @intergace without giving it @property (nonatomic, ass开发者_高级运维ign) or synethezing it.

I just put int anInteger in the @intergace without giving it @property (nonatomic, ass开发者_高级运维ign) or synethezing it.

Should I be giving it a property?


It depends. I try to always use properties. Even though it has some (constant) overhead, it makes my code clearer. If you ever want to refactor the class, it makes it a lot easier if users (which might just be yourself) don't depend on your ivar.

Also, if you ever want to do Key-Value Observing then having a property with synthesized accessors makes sure your class is KVO-compliant.

0

精彩评论

暂无评论...
验证码 换一张
取 消