【发布时间】:2012-01-17 14:25:42
【问题描述】:
在 Objective C 中,您现在可以使用 @property 和 @synthesize 自动生成 get 和 set 方法。我的问题是:我还需要在界面中声明属性吗?没有它,我的程序编译并运行良好。但是大多数书籍和其他示例仍然有它。为什么?
@interface Person : NSObject {
// do i need the declaration "NSString name;"? why?
// i have notice that my program works fine without it.
// but many programming examples still incude it.
// NSString name;
}
@property NSString *name;
@end
@implementation Person
@synthesize name;
@end
【问题讨论】:
标签: iphone objective-c ipad ios5 properties