Declare properties in .h interface or in an extension in .m file?

白昼怎懂夜的黑 提交于 2019-11-30 05:00:19
zaph

First, as of Xcode 4.4 there is no longer a need to @synthesize(unless you change both the setter and getter method), either when the @property is declared in the @interface or @implementation.

If the @property is only accessed from within the class then declare the @property in a class extension in the .m file. This provides encapsulation and make it easy to see that the @property is not used from another class.

If the @property is used by other classes, by design, then define it in the @interface in the .h file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!