Я впервые использую протоколы в Objective-C и столкнулся с проблемой: вот что у меня есть:
У меня есть ReportsReceiver.h:
@protocol ReportsReceiver
-(void)receiveData:(NSArray *)theData;
@end
У меня есть MyController.h:
@interface MyController : UIViewController<ReportsReceiver,UITableViewDelegate,UITableViewDataSource> {
}
@end
У меня есть MyController.m с реализованным методом:
- (void)receiveData:(NSArray *)theData {
NSLog(@"received some data!");
}
А затем у меня есть класс AllUtilities.m собъявление:
Protocol *receiverProtocol;
AllUtilities.m также содержит метод для инициализации протокола:
- (void)initProtocol {
receiverProtocol = @protocol(ReportsReceiver);
}
А затем в AllUtilities.m я делаю вызов:
[receiverProtocol receiveData:anArray];
Который вылетает приложение с ошибкой:
2011-01-07 11:46:27.503 TestGA[91156:207] *** NSInvocation: warning: object 0x9c28c of class 'Protocol' does not implement methodSignatureForSelector: -- trouble ahead
2011-01-07 11:46:27.504 TestGA[91156:207] *** NSInvocation: warning: object 0x9c28c of class 'Protocol' does not implement doesNotRecognizeSelector: -- abort
Как это исправить?Спасибо !!