Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm getting this warning.

'-respondsToSelector:' not found in protocol(s)

It occurs on the line marked by "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;
}

Heres my full h files.

#import <UIKit/UIKit.h>


@interface SettingsTableViewController : UITableViewController {
    NSArray *sectionControllers;

}

@end

What do i need to do to fix the error?

like image 387
Jules Avatar asked Dec 09 '22 13:12

Jules


1 Answers

Either make SetsSectionController inherit from NSObject:

@protocol SetsSectionController <NSObject>

...or cast to id:

if ([(id) sectionController respondsTo...])
like image 63
zoul Avatar answered May 13 '23 15:05

zoul