Difference between @property and variable within interface declaration
本问题已经有最佳答案,请猛点这里访问。
把一个变量放在头文件中的
例如。,
1 2 3 4 5 | @interface GameCenterManager : NSObject { GKInvite* pendingInvite; } @end |
而不是
1 2 3 | @interface GameCenterManager : NSObject @property (weak, nonatomic) GKInvite* pendingInvite @end |
Declaring a property generates getters and setters for the instance variable, according to the criteria within the parenthesis.
Defining the variables in the brackets simply declares them instance variables.
以下是一些提供更多信息的链接。
http://www.cocoawithlove.com/2010/03/dynamic-ivars-solving-friable-base.html
目标C中的"实例变量"和"属性"之间有区别吗?
http://iphonedevelopment.blogspot.in/2008/12/outlets-property-vs-instance-variable.html