What name does the auto-generated ivar take when I just declare a property in XCode 4.5 onwards?

寵の児 提交于 2019-12-17 21:13:10

问题


Earlier I was on XCode 4.2 for a long time on Snow Leopard for a long time. I have made a straight jump to Mountain Lion with XCode 4.5 on with iOS 6 SDK and ARC.

A lot has changed for me. Just wanted to know, whether the naming style of default variables has changed ?

because in older XCode if I wont declare an ivar myself, it would take the same name as the property.

In 4.5, I declared a property (no synthesize required anymore!).

In the overidden setter, I am trying to use the variable as the same name as the property, say abc.

but XCode is not recognizing it and giving me suggestions of _abc !

Does the auto-generated ivar starts with _ now ?


回答1:


The automatically generated @synthesize statement uses instance variables prepended with an underscore:

@synthesize abc = _abc;

But an explicit @synthesize statement without instance variable

@synthesize abc;

is still equivalent to

@synthesize abc = abc;

for compatibility with older Xcode versions.



来源:https://stackoverflow.com/questions/14556232/what-name-does-the-auto-generated-ivar-take-when-i-just-declare-a-property-in-xc

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