Hello, I have the following class:
@interface Gamer {
...
}
+(id) CreatePlayer;
@end
@implementation Gamer
+(id) CreatePlayer
{
return [[[self alloc] init]autorelease];
}
@end
I need to use the Gamer in an another class as instance variable. For example like this:
@interface Layer{
Gamer * mCenterGamer;
}
@end
@implementation
-(void) init{
mCenterGamer = [Gamer CreatePlayer];
}
-(void) exampleFuncForUseGamer{
[mCenterGamer ...]// some methods of the Gamer class
}
@end
Is it correct? (I think autorelease freed the mCenterGamer after exiting from the init function)