将变量放在 @interface{}
中有何区别?在头文件中声明,并放入 @property
在该声明之后?
例如,
@interface GameCenterManager : NSObject
{
GKInvite* pendingInvite;
}
@end
相对于
@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-fragile-base.html
Is there a difference between an "instance variable" and a "property" in Objective-c?
http://iphonedevelopment.blogspot.in/2008/12/outlets-property-vs-instance-variable.html
关于ios - 接口(interface)声明中@property和变量之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16661911/