How to mark designated initializers of super class "invalid" in Objective-C? -
from adapting modern objective-c document:
if class provides 1 or more designated initializers, must implement of designated initializers of superclass.
that means if have subclass of nsobject
has own designated initializer,
- (instancetype)initwithimage:(uiimage*)image ns_designated_initalizer;
then need provide implementation of nsobjects -init
. should mark -init
initializer "invalid", i.e., nobody should call use -initwithimage:
instead? what's best practice here?
edit
i tried techniques described here.
however, when mark superclass -init
method unavailable
in interface, compiler still tells me need overwrite initializer of superclass.
when try other techniques, i.e., raising exception or calling -doesnotrecognizeselector:
inside of -init
, error stating need call 1 of designated initializers.
Comments
Post a Comment