Monday, 9 September 2013

Objective-c: Questions about self = [super init]

Objective-c: Questions about self = [super init]


I have seen self = [super init] in init methods. I don't understand why.
Wouldn't [super init] return the superclass? And if we point self = [super
init], are we not getting self = superclass?
Here's an example code fragment
- (id)init {
if (self = [super init]) {
creationDate = [[NSDate alloc] init];
}
return self;
}
Hope someone can clarify this for me. Thank you.

No comments:

Post a Comment