如何解决此分析问题:
CODE
if(![super initWithFrame:CGRectZero]){
return nil;
}
firstOfPrev = -1;
marks = markArray;
monthDate = date;
startOnSunday = sunday;
答案 0 :(得分:1)
您收到错误是因为您从未将超级初始化程序调用的结果分配给self。我相信这就是你想要的:
- (instancetype)initWithFrame:(CGRect)frame
{
if (!(self = [super initWithFrame:frame])) {
return nil;
}
// do stuff
return self;
}
但是,如果你写出这样的初始化器,这可能会更清楚:
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// do stuff
}
return self;
}