ary*_*axt 2 inheritance objective-c
- (id) init
{
[super init];
//initialitation of the class
return self;
}
Run Code Online (Sandbox Code Playgroud)
我知道当我从另一个班级继承时,我想要打电话 super.init
这是否适用于"继承自NSObject"?
是的,通常你有类似的东西:
- (id) init
{
if (self = [super init]) {
// instantiation code
}
return self;
}
Run Code Online (Sandbox Code Playgroud)