I want to use an static function from a protocol in a function:
@implementation IPadPanoramaViewController
- (void)viewDidLoad
{
[self.view addSubview:[PanoramaContent getPanoramaContentByPanoramaItem:[[PanoramaListItem alloc] init]];
[super viewDidLoad];
}
@end
@protocol PanoramaItemProtocol
+ (UIView *) getPanoramaItemBySection;
@end
@implementation PanoramaContent
+ (UIView *) getPanoramaContentByPanoramaItem:(id<PanoramaItemProtocol>) itemKind {
return [itemKind getPanoramaItemBySection]; //here is the problem "unrecognized selector sent to instance"
}
@end
I wish “PanoramaListItem” don’t be a NSObject
The problem is that you’ve defined
getPanoramaBySectionto be a class method, when you’re calling it on an instance. In the protocol declaration, replace the+with a-.