Can a protocol can be inherited privately so that in next inheritance level this should not be accessed ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Objective-C has no “private inheritance” (or “private conformance”) the way C++ does.
You can conform to a protocol without advertising your conformance in your header file. For example, you can conform to
NSCoding“secretly” if you put this above your@implementationstatement in your.mfile:That declares a class extension that adds the
NSCodingprotocol to theMyObjectclass.However, anyone (including a subclass) can ask whether you adopt the protocol:
and anyone can send an
NSCodingmessage to aMyObjectby casting the object first:And if you make a subclass of
MyObject, and your subclass also declares that it conforms toNSCoding, then it almost certainly needs to call[super encodeWithCoder:]from its ownencodeWithCoder:method.