【发布时间】:2011-02-21 20:33:20
【问题描述】:
我对属性的两个假设是否正确?
@interface Foo : NSObject {
NSDate *Created;
}
@property (nonatomic, retain) NSDate *Created;
@end
@implementation Foo
@synthesize Created;
- (id) init {
if(self = [super init])
{
Created = [NSDate date]; //this will not call the setter and instead just access the variable directly, which means it will not automatically get retained for me.
self.Created = [NSDate date]; // this will call the setter, which will retain the variable automatically for me.
}
return self;
}
- (void)dealloc {
[Created release]
[super dealloc];
}
@end
【问题讨论】:
标签: iphone objective-c properties