Say i create a viewController. Then I want to create another viewController that’s like the first one. Looks like a job for inheritance.
However, many of the task of the originalViewController are private methods and I want to minimize public interface.
If I declare those methods public then well, the objective of keeping private things private is not achieved.
If I declare those methods private, then the child class do not know those methods.
If I create a special .h files for the child class, it’ll be awkward.
So what’s the industry standard way of doing this sort of thing anyway?
In C++ we would use protected methods or function to accomplish this right?
Update:
I put
#import "BGGoogleMap+protected.h"
@implementation BGGoogleMap ()
@end
It doesn’t work. It asks for identifier.
In addition to what Catfish_Man suggests, you can make categories on your class that only your subclasses have access to. Here are the docs for how to do that. Basically, you just create a new interface for your class and put any private methods in there. Like this:
Put those in Foo_Internal.h, and include Foo_Internal.h in your subclasses, but don’t make it public.