erosebe
erosebe

Reputation: 967

can't figure out unrecognized selector sent to instance for XMLparser

I had a function XMLParser working but I'm trying to expand the class to handle different XML files my app needs.

I'm getting the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XMLParser initXMLParserForValidation]: unrecognized selector sent to instance 0x7564ea0'" Here's the code there.

- (void)validateEmail:(NSString *)urlString {
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
NSXMLParser *nsXmlParser = [[NSXMLParser alloc] initWithData:data];
XMLParser *parser = [[XMLParser alloc] initXMLParserForValidation];
[nsXmlParser setDelegate:parser];

BOOL wasSuccessful = [nsXmlParser parse];

if (wasSuccessful) {
    self.result = [parser result];
} 
}

I've put breakpoints and stuff and but doesn't even get into my initXMLParserForValidation class. Here it is anyway, though.

- (XMLParser *) initXMLParserForValidatation {
self = [super init];
_result = [[ValidationResult alloc] init];
return self;
}

I've tried to mimic the code that's working but I can't see any differences. Driving me nuts. I'm new at this iphone stuff, though. Help much appreciated.

Upvotes: 1

Views: 245

Answers (1)

Aaron
Aaron

Reputation: 7145

There's a spelling error in the declaration of your class' init method:

initXMLParserForValida*ta*tion

Then you're calling the init method like this, with the proper spelling, which doesn't exist:

initXMLParserForValidation

Remove the extra ta and you should be good to go!

Upvotes: 3

Related Questions