Xcode:错误类XYZ没有实现'NSXMLParserDelegate'协议

时间:2011-08-24 23:30:27

标签: iphone xcode

我收到有关“[parser setDelegate:self];”行的错误消息下面:

Class'ProcessiController'没有实现'NSXMLParserDelegate'协议......

这是代码:

<!-- 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");

}

这是.h文件:

<!-- 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;

}

感谢您的贡献!但是,只有逐步解释要修改的内容才有用,因为我没有编程知识(但我很勇于修补代码:-))

1 个答案:

答案 0 :(得分:2)

使用以下行

[parser setDelegate:self];

表示当前类符合NSXMLParserDelegate协议。

要使其工作,您需要做的是让当前的类实现所需的委托方法。

以下是一些解释Protocols在iOS中如何运作的链接:

iOS protocols and delegates. Basic questions

http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html