NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION does not throw warning
I meant this link (used for google translate) - about NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION
I am trying to get NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION
to throw a warning in my project when a required method in the protocol needs to be implemented and for all subclasses.
Here the protocol is -
NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION
@protocol ExplicitProtocol <NSObject>
@required
- (void)requiredMethod1;
- (void)requiredMethod2;
@optional
- (void)optionalMethod1;
- (void)optionalMethod2;
@end
Base Class Header -
@interface BaseClass : NSObject<ExplicitProtocol>
@end
Base class implementation -
@implementation BaseClass
-(void)requiredMethod1
{
}
-(void)requiredMethod2
{
}
@end
SubClass header
@interface SubClass : BaseClass
@end
SubClass implementation
@implementation SubClass
//No protocol methods implemented here
@end
Since the required methods are not implemented in SubClass
, I want to raise a warning.
Is there a way to achieve this in Objective C? What am I doing wrong here?
+3
source to share
No one has answered this question yet
Check out similar questions: