> On Jun 9, 2015, at 4:18 PM, Quincey Morris > <[email protected]> wrote: > > I was half-right before, in that using ’NS_DESIGNATED_INITIALIZER’ enables > different rules for initializers in the compiler. Once you use that on an > initializer that has parameters, you must override parameterless ‘init’ too, > and the override has to be a designated initializer.
Hm. Where did you find the documentation of that? It seems wrong to me to force an NSObject subclass to declare -init as a designated initializer even if it isn’t a valid initializer at all; there are a lot of classes that it doesn’t make sense to instantiate with no parameters. For instance, look at the declaration of NSValue, copied directly out of NSValue.h: @interface NSValue : NSObject <NSCopying, NSSecureCoding> - (void)getValue:(void *)value; @property (readonly) const char *objCType NS_RETURNS_INNER_POINTER; - (instancetype)initWithBytes:(const void *)value objCType:(const char *)type NS_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; @end It declares two designated initializers that take parameters, and there’s no plain -init declared at all. I just wonder what the @implementation of that looks like — presumably the compiler made them put in a -init method, so what does it do? —Jens
_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com This email sent to [email protected]
