Is there a way to have “private” methods in a superclass (which are not in its header file) and still be able to access these from subclasses?
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.
You could use a custom category, for example:
Stuffy.h
Stuffy+Secret.h
Stuffy.m
Subclasses of
Stuffycan now either importStuffy.hin their.mfiles and stick to the public API, or importStuffy+Secret.hand use the semi-protected stuff.Note, that Objective-C has no true notion of
protectedorprivatemethods. Basically, anyone can includeStuffy+Secret.hand use the stuff declared there.