【发布时间】:2015-01-18 15:38:26
【问题描述】:
我正在学习如何在 Objective-C 中创建自定义 INIT。似乎有两种方法可以做到这一点。这两种创建自定义初始化的方法有什么区别吗?
//First way of creating a custom init uses instancetype
-(instancetype) init
{
self = [super init];
if (self) {
//initialization code here
}
return self:
}
//Second way of creating a custom init uses ID
- (id)init {
self = [super init];
if (self) {
//initialization code here
}
return self;
}
【问题讨论】:
标签: objective-c initialization instancetype