我收到此警告。
“-respondsToSelector:”在协议(protocol)中找不到
它出现在下面标有“HERE”的行上。
- (NSString *)tableView:(UITableView *)tableView
titleForFooterInSection:(NSInteger)section {
id<SetsSectionController> sectionController =
[sectionControllers objectAtIndex:section];
if ([sectionController respondsToSelector:
@selector(tableView:titleForFooterInSection:)]) { //HERE
return [sectionController tableView:tableView
titleForFooterInSection:section];
}
return nil;
}
这是我的完整 h 文件。
#import <UIKit/UIKit.h>
@interface SettingsTableViewController : UITableViewController {
NSArray *sectionControllers;
}
@end
我需要做什么来修复错误?
最佳答案
要么让SetsSectionController
继承自NSObject
:
@protocol SetsSectionController <NSObject>
...或转换为id
:
if ([(id) sectionController respondsTo...])
关于iPhone,如何修复此警告 : '-respondsToSelector:' not found in protocol(s),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3777971/