I'm writing an App that is parsing Data from an XML-Doc on the web. So when it finishes loading it is supposed to call the Parsing Method as follows.
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
[self startParsingData];
}
This should work in theory, right? Problem is I'm getting this error:
Reciever type 'ffwDetailViewController' for instance message does not declare a method with selector 'startParsing Data'
I take it, that xCode thinks this method doesn't exist., but it does.
-(void)startParsingData{
NSXMLParser *dataParser = [[NSXMLParser alloc] initWithData:recievedData];
dataParser.delegate = self;
[dataParser parse];
}
I don't know what to do. I would really appreciate any help.
Switching their Position did the trick. Unfortunately, now the app crashes on pressing the Button. Here's the full code. I hope you can help me.
- (IBAction)getMissions:(id)sender {
if (recievedData) {
recievedData = nil;
}
_einsaetze.text=@"Pasing Data...";
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://oliverengelhardt.de/ffw_app/test.xml"]]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
//Start loading Data
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
recievedData = [NSMutableData data];
}else{
[_einsaetze setText:@"connection failed"];
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
[recievedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
if (recievedData) {
[recievedData appendData:data];
}
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
_einsaetze.text=@"connnection failed";
}
-(void)startParsingData{
NSXMLParser *dataParser = [[NSXMLParser alloc] initWithData:recievedData];
dataParser.delegate = self;
[dataParser parse];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
[self startParsingData];
}
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
if ([elementName isEqualToString:@"element"]) {
NSString *myData = [NSString stringWithFormat:@"%@", [attributeDict objectForKey:@"myData"]];
_einsaetze.text = myData;
}
}
If -(void)startParsingData
is not declared in the @interface
section of the class (either in the .h or in an extension in the .m file) then -(void)startParsingData
needs to be physically before -(void)connectionDidFinishLoading
in the .m file.
What order are they in your .m file?