【发布时间】:2013-09-09 07:04:02
【问题描述】:
我在 init 方法中看到了self = [super init]。我不明白为什么。 [super init] 不会返回超类吗?如果我们指向self = [super init],我们不会得到self = superclass吗?
这是一个示例代码片段
- (id)init
{
if (self = [super init]) {
creationDate = [[NSDate alloc] init];
}
return self;
}
希望有人可以为我澄清这一点。谢谢你。
【问题讨论】:
-
搜索“isa指针”。
-
这里解释得很好:cocoawithlove.com/2009/04/….
标签: ios objective-c