Iphone, how can I fix this warning: '-respondsToSelector:' not found in protocols (s)

I get this warning.

'- replies SoSelector:' not found in protocol (s)

This happens on the line labeled HERE below.

- (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; } 

Here are my complete h files.

 #import <UIKit/UIKit.h> @interface SettingsTableViewController : UITableViewController { NSArray *sectionControllers; } @end 

What do I need to do to fix the error?

+4
source share
3 answers

Or make SetsSectionController inherit from NSObject :

 @protocol SetsSectionController <NSObject> 

... or apply to id :

 if ([(id) sectionController respondsTo...]) 
+12
source
 if ([(NSObject *)sectionController respondsToSelector: @selector(tableView:titleForFooterInSection:)]) 
+1
source

Someone needs

 SEL selector = NSSelectorFromString(@"tableView:titleForFooterInSection:"); if([sectionController respondsToSelector:selector]) { objc_msgSend(sectionController, selector, tableview, section); } 

Note. Do not forget about it, #import <objc/message.h>

+1
source

All Articles