libobjc: @protocol doesn't retrieve valid class pointer
Michael Scheibler
michael.scheibler@onevision.de
Mon Jan 22 04:52:00 GMT 2001
When I create an instance of my protocol using the statement
@protocol(TestProtocol), I can't invoke any method of it. As I ran
through the code using gdb, I found out, that the class pointer of this
structure is not set correctly.
However, if I have an implementation of the protocol inside the same
bundle, the problem doesn't occur.
Michael
#include <Foundation/Foundation.h>
@protocol TestProtocol
- (void) doSomething;
@end
/** Code crashes without this implementation
@interface Test : NSObject <TestProtocol>
@end
@implementation Test
- (void) doSomething
{
printf("Did Something\n");
}
@end
**/
int main(int argc, char* argv[])
{
Protocol *pr;
pr = @protocol(TestProtocol);
printf("Protocol name: %s\n", [pr name]);
return 0;
}
More information about the Gcc-bugs
mailing list