I built a custom class named game:
.h
-(void) init;
here I have a Also found '-(void) init'
.m
-(void) init {
[super init];
score = 0;
lives = 3;
elements = [[NSMutableArray alloc] initWithCapacity:1000];
}
when I try to开发者_如何学Python initialize a object with:
myGame = [[Game alloc] init];
I got "Multiple methods named '-init' found So I don't know where the error is...
init should always return (id). Change your function to the following:
.h
-(id) init;
.m
-(id) init {
if((self = [super init]))
{
score = 0;
lives = 3;
elements = [[NSMutableArray alloc] initWithCapacity:1000];
}
return self;
}
精彩评论