I have the following class hierachy:
@interface Message : NSObject {}
@end
@implementation Message
- (void) dealloc
{
// I won't be called
[super dealloc];
}
@end
@interface FooMessage : Message {}
@end
@implementation FooMessage
- (void) dealloc
{
// should call Message - dealloc
[super dealloc];
}
@end
And the following unit test:
- (void) test
{
FooMessage* msg = [[FooMessage alloc] init];
[msg release];
}
The test will always fail with EXC_BAD_INSTRUCTION. FooMessage
calls it's super class destructor in dealloc
, but the call never arrives there. Instead, the Objective-C runtime resolves the call to a different location:
The error doesn't occur if the Message
base class is renamed to something else, e.g. AbstractMessage
. It appears there is another class named Message
, whose definition is not publicly available.
Is this a bug? What's really happening here? Am I violating any naming restrictions (even though I think the compiler should warn me about that)?.
It's XCode 3.1. compiling for iPhone OS 3.0.