objective-c – Xcode 4在使用@属性时自动生成iVars,在哪里可以找到此功能的官方文档?

前端之家收集整理的这篇文章主要介绍了objective-c – Xcode 4在使用@属性时自动生成iVars,在哪里可以找到此功能的官方文档?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我读过“ Xcode中的新功能”,但我找不到此功能的官方解释.
我在哪里可以找到官方解释?哪个文件?谢谢.

解决方法

您可以在 Objective-C Programming Language: Declared Properties的“财产实施指令”下的Apple文档中找到此信息.是否自动合成ivar取决于您使用的运行时间:

There are differences in the behavior of accessor synthesis that depend on the runtime (see also “Runtime Difference”):

  • For the legacy runtimes,instance variables must already be declared in the @interface block of the current class. If an instance variable of the same name as the property exists,and if its type is compatible with the property’s type,it is used—otherwise,you get a compiler error.
  • For the modern runtimes (see “Runtime Versions and Platforms” in Objective-C Runtime Programming Guide),instance variables are synthesized as needed. If an instance variable of the same name already exists,it is used.

iOS总是使用现代运行时,因此您永远不需要显式声明ivars.

猜你在找的Xcode相关文章