Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there @protected method?

I want to declare a method in a BaseObject, and this method only implemented by the SubObject, how can I do that? I found @protected is permitted to be used on method.

like image 965
Mil0R3 Avatar asked Jan 14 '23 14:01

Mil0R3


1 Answers

One way around this is to create a private header file containing a private interface category, like this:

//MyClass.h

@interface MyClass : NSObject

- (void)publicMethod;

@end

//MyClass_private.h

@interface MyClass ()

- (void)protectedMethod;

@end

MyClass.m and it's subclasses import the regular and _private headers, giving the _private declarations the same scope as protected. Customers of the hierarchy use only the regular headers.

like image 101
danh Avatar answered Jan 22 '23 09:01

danh