I have got a strange bug I cannot seem to figure out. I've got a class called SPGamePlayScene. I also have a class called SPPracticeScene with inherits from SPGamePlayScene. I want SPPracticeScene to do all the stuff SPGamePlayScene does in its initializer so Ive overridden it and added some other code to it. However whenever I initialize an SPPracticeScene object, It creates two instead of one. I think it must have something to do with my initializers. below is the initializer for SPGamePlaySCene:
//SPGamePlayScene.m
- (id)initWithSize:(CGSize)size colored:(BOOL)colored {
if (self = [super initWithSize:size]) {
//lots of custom setup here
}
return self;
}
it looks like a pretty standard initializer to me.
then below is the initializer for SPPracticeScene. it calls its superclass's (SPGamePlayScene) initializer method above and then does some custom setup as well
//SPPracticeScene
- (id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size colored:NO]) {
//custom setup here
//this log runs twice. the memory adress shown is different each time
NSLog(@"practice scene: %p", self);
}
return self;
}
can anybody tell me why its running twice and two different objects are being created?