Xcode: error Class XYZ does not implement the 'NSXMLParserDelegate' protocol
I get this error message regarding the line "[parser setDelegate:self];" below:
Class 'ProcessiController' does not implement the 'NSXMLParserDelegate' protocol...
This is the code:
<!-- language: C-objective -->
@implementation ProcessiController
-(void)awakeFromNib
{
NSString *dataFilePath = [[NSBundle mainBundle] pathForResource:@"processi" ofType:@"xml"];
stories = [[NSMutableArray alloc]init];
parser = [[NSXMLParser alloc] initWithData:[开发者_开发问答NSData dataWithContentsOfFile:dataFilePath]];
[parser setDelegate:self];
[parser parse];
NSLog(@"file trovato e caricato");
}
And this is the .h file:
<!-- language: C-objective -->
#import <UIKit/UIKit.h>
#import "CustomCellProcessiController.h"
#import "GenericaProcessiController.h"
@interface ProcessiController : UITableViewController {
NSXMLParser *parser; //utilizzato per il parsing
NSMutableArray *stories;
NSMutableDictionary *item;
NSString *currentElement;
NSMutableString *currentName;
NSMutableString *fileName;
UIView *myHeader;
}
Thanks for any contribution! However, it will be helpful only if explained step by step what to modify since I have no programming knowledge (but am brave enough to tinker with the code :-) )
By using following line,
[parser setDelegate:self];
you indicate that the current class conforms to the NSXMLParserDelegate
protocol.
What you need to do to make it work is to have your current class implement the required delegate methods.
Here are some links that explain how Protocols
work in iOS:
iOS protocols and delegates. Basic questions
http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html
精彩评论