'자기'에 할당해야합니다대리인 초기화 호출의 결과는 즉시 반환 또는 I는 다음과 같은 방법을 선언하는 클래스가 내 프로젝트에서
-(id)initWithSections:(NSUInteger)s rows:(NSUInteger)r
{
if(self=[self init])
{sections = [[NSMutableArray alloc] initWithCapacity:s];
for (int i=0; i<=s; i++){
NSMutableArray *rows = [NSMutableArray arrayWithCapacity:r];
for (int j=0; j<=r; j++){
[rows insertObject:[NSNull null] atIndex:j];
}
[sections addObject:rows];
}
}
return self;
}
을 나는 또한 방법 위를 호출하는 또 하나 개의 방법 :
The result of a delegate init call must be immediately returned or assigned to 'self'.
I 오류가 표시되지 않습니다 :
-(id)OneMoreMethod:(NSMutableArray *)obj1 :(NSMutableArray *)obj2
{
NSInteger b = 3;
[self initWithSections:b rows:b];//The result of a delegate init call must be immediately returned or assigned to 'self'
return self;
}
나는 오류가 발생했습니다. 가장 흥미로운 것은 다른 프로젝트에서 성공을 거두는 것입니다.
당신은 호출하지 않아야'[자기 초기화 ...]'에서을 비 초기화 메소드. – rmaddy
반환 값 "id"를 "instancetype"으로 변경하십시오. 그리고 코드에서 충분한 경고 가까이에서 아무 것도 켜지 않았으므로 완전히 피할 수있는 버그를 예상하여 디버깅하는 데 많은 시간을 들여야합니다. – gnasher729