2011-08-24 49 views
1

我得到這條錯誤消息關於行「[parser setDelegate:self];」如下:Xcode:錯誤類XYZ沒有實現'NSXMLParserDelegate'協議

班 '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; 

} 

感謝您的貢獻!然而,這將是有幫助的只有一步一步解釋修改什麼,因爲我沒有任何編程知識(但我有足夠的勇氣與代碼:-)鼓搗)

回答

2

通過使用以下行,

[parser setDelegate:self]; 

您指出當前類符合NSXMLParserDelegate協議。

你需要做的是讓你的當前類實現所需的委託方法。

這裏有一些鏈接,解釋如何在iOS中Protocols工作:

iOS protocols and delegates. Basic questions

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

+0

非常漂亮的你回答沙哈里亞爾,我會考慮它儘快,乾杯! – Artur

+0

嗨,我遵循鏈接,但我真的很容易解釋我的代碼中我應該應用什麼變化來擺脫錯誤,謝謝你的理解。 – Artur

+0

請保存一個noob的生活,謝謝! – Artur

相關問題