gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 19:04:18 25 4
gpt4 key购买 nike

我收到此警告。

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com