1

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.

4

1 回答 1

3

您的类的 init 方法的声明中存在拼写错误:

initXMLParserForValida* ta *tion

然后你像这样调用 init 方法,使用正确的拼写,但不存在:

initXMLParserForValidation

删除多余的ta,你应该很高兴!

于 2013-05-13T21:14:06.017 回答