Possible Duplicate:
isMemberOfClass returns no when ViewController is instantiated from UIStoryboard
I recently stumbled over a weird problem:
I was implementing simple Testcases and using the NSObject isMemberOfClass method to check for class equality.
Additionally I implemented a custom init:
-(id)initWithMessage:(NSString *)message
If I replace id with the right class name the isMemberOfClass will return 'YES'. Otherwise it will fail.
The interesting part is: The class Method will return the right Class every time.
Is this a bug? Or is it supposed to work that way?
Thanks..
EDIT:
Ok this did not solve the problem.. Here is what I do.. isMemberOfClass will always return NO
Testcase:
- (void)test010_broadcastWait
{
...
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData
options:0 error:&error];
Brick *newBrick = [self.parser loadBroadcastWaitBrick:doc.rootElement];
if (![newBrick isMemberOfClass:[BroadcastWaitBrick class]])
STFail(@"Wrong class-member");
....
}
BroadCastWait Class:
import "BroadcastWaitBrick.h"
@implementation BroadcastWaitBrick
-(id)initWithMessage:(NSString *)message
{
self = [super init];
if (self)
{
self.message = message;
}
return self;
}
...
loadMethod:
-(BroadcastWaitBrick*)loadBroadcastWaitBrick:(GDataXMLElement*)gDataXMLElement
{
NSArray *messages = [gDataXMLElement elementsForName:@"broadcastMessage"];
GDataXMLElement *message = (GDataXMLElement*)[messages objectAtIndex:0];
BroadcastWaitBrick* brick = [[BroadcastWaitBrick alloc]initWithMessage:message.stringValue];
return brick;
}