ody*_*yth 0 iphone properties objective-c
我对属性的两个假设是否正确?
@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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
362 次 |
| 最近记录: |