Objective-C - readonly properties not synthesized with underscore ivar?

人走茶凉 提交于 2019-11-29 02:53:30

A property is not automatically synthesized if you implement all required accessor methods (getter for a read-only property, getter + setter for a read-write property).

Because you implement the getter method -(NSString *)myString for the read-only property, it is not auto-synthesized. If your getter needs an instance variable to backup the property value, you have to add the synthesize statement (as you did) or an instance variable.

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