I found a part of a code written by someone else.
@interface Fly : CCSprite
{
id var1;
id var2;
}
Then in the .m file
- (void) dealloc
{
[var1 release];
[var2 release];
// don't forget to call "super dealloc"
[super dealloc];
}
It is written right? I don’t think the id type can be released. Maybe the isa variable in it… Can you explain me why this is released? Or can you help me to explain why is this bad?
idcan hold any object, and when you send a message to it, it may or may not respond to it. If it does respond torelease(which most classes in Cocoa do, as they’re subclassingNSObject) it will be released. Depending on which OS this is being run on, you may get an exception if the object does not respond to the message (iOS throw an exception, OS X logs and continues), but that can be checked at runtime usingrespondsToSelector:.