How come Apple changed the built-in init
method snippet from:
- (id)init
{
self = [super init];
if (self) {
}
return self;
}
to:
- (instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
?
How come Apple changed the built-in init
method snippet from:
- (id)init
{
self = [super init];
if (self) {
}
return self;
}
to:
- (instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
?
instancetype
is the best return type for Objective-C init methods. If you write id
instead of instancetype
in an init method then the compiler will assume you really meant instancetype
(at least in ARC mode).