On Jun 9, 2015, at 15:23 , Sean McBride <[email protected]> wrote:
>
> I also tried:
>
> - (instancetype)init
> {
> assert(0);
> }
>
> Thinking maybe it would clue in on an old school assert, but no.
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.
However, the syntax I suggested was wrong. You can only use
’NS_DESIGNATED_INITIALIZER’ in an @interface block, so you’d actually do it
like this (in the .m file):
> @interface MyClass ()
> - (instancetype) init NS_DESIGNATED_INITIALIZER;
> @end
>
> @implementation MyClass
> - (instancetype) init {
> assert (0);
> }
Note that if you have other private initializer methods in the @implementation
block only, you’ll have to pre-declare them in the class extensions so that you
can mark the ’NS_DESIGNATED_INITIALIZER’ too.
I tried this in an actual source file, and the warnings did go away.
_______________________________________________
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]