iPhone,如何修复此警告 : '-respondsToSelector:' not found in protocol(s)

标签 iphone xcode uitableview iphone-sdk-3.0

我收到此警告。

“-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/

相关文章:

ios - 嵌套 Alamofire 请求

iphone - 使用 AutoLayout 进行旋转

ios - React Native 在为 TestFlight 发布 iOS 应用程序后进行更改和更新

ios - 为什么我不能从另一个类访问我的 UIView 的类属性?

ios - 如何创建一个包含多个 CollectionView 的 TableView Cell?

ios - 如何将整个表格 View 捕获为图像,从中创建 .pdf 并通过电子邮件发送

iphone - 自定义 UIView iboutlet 未设置

ios - 如何用图像替换 UIView?

ios - 运行 IOS 模拟器后未找到 YogaKit.modulemap

swift - 将 UIToolBar 添加到 TableViewController (Swift)