我已经读了很多片段,提到你不应该在你的init或者dealloc方法中使用点符号.但是,我似乎无法找出原因.一个帖子经常提到它与KVO有关,但没有更多.
@interface MyClass : NSObject { SomeObject *object_; } @property (nonatomic,retain) SomeObject *object; @end
这个实现是坏的?
@implementation MyClass @synthesize object = object_; - (id)initWithObject:(SomeObject *)object { if (self = [super init]) { self.object = object; } return self; } @end
但这是好的?
@implementation MyClass @synthesize object = object_; - (id)initWithObject:(SomeObject *)object { if (self = [super init]) { object_ = [object retain]; } return self; } @end
在init中使用点符号的缺陷是什么?