Hello everyone,
New here. I have a question related to initialization and memory.
I have a class (I am using cocos2D but is related to general Objective-C i guess) with initialization as follows:
I initialize this class in another class without an object:
This works fine but the MyClass' dealloc method is not called and crashes since some resources are not freed.
This is totally puzzling and can't find anything online. If anyone would suggest a solution or an alternative method, i'd really appreciate it.
Thank you.
New here. I have a question related to initialization and memory.
I have a class (I am using cocos2D but is related to general Objective-C i guess) with initialization as follows:
Code:
@implementation MyClass
+(id) initializeMyClass
{
return [[[self alloc] initMyClass] autorelease];
}
-(id) initMyClass
{
if (([self = [super init]))
{
}
return self;
}
-(void) dealloc
{
NSLog(@"Deallocating");//I also used CCLOG instead.
[super dealloc];
}
@end
I initialize this class in another class without an object:
Code:
[MyClass initializeMyClass];
This works fine but the MyClass' dealloc method is not called and crashes since some resources are not freed.
This is totally puzzling and can't find anything online. If anyone would suggest a solution or an alternative method, i'd really appreciate it.
Thank you.