开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜