Let's say I create a protocol with a custom initializer in it so that I want some of my object objects to match.
@protocol SomeProtocol <NSObject> - (instancetype)initWithContext:(Context *)context; @end
However, I also want to make -[NSObject init] inaccessible. The way I did this in the past is the ad in the header:
- (instancetype)init NS_UNAVAILABLE;
or
- (instancetype)init __attribute__((unavailable("Use -initWithContext:")));
Is there a way to include something like the above in the protocol, so that any class matching this protocol will have its default initialization methods that are not available?
To be explicit, I am wondering if something like the following is really:
@protocol SomeProtocol <NSObject> - (instancetype)initWithContext:(Context *)context; - (instancetype)init __attribute__((unavailable("Use -initWithContext:"))); @end
source share