On Oct 19, 2014, at 00:56 , Rick Mann <rm...@latencyzero.com> wrote:
> 
> The subclass initializer still has to initialize itself. It knows what the 
> superclass initializer is doing, and it knows what it still needs to do. 
> That's true even with the rules Swift currently imposes.

I don’t actually know what “initialize itself” means. Nor do I see how it 
“knows” what the superclass is doing, or at least I’m uncertain how this helps.

>> In Swift, an external caller cannot initialize a class by calling one of its 
>> superclass initializers

> Of course, not, and I'm not suggesting that at all.

FWIW, I’m not sure there’s an “of course” here. In Obj-C, of course it can 
literally do this.

However, going back to your original post, you wrote this:

> I tried this:
> 
> 16    override
> 17    init()
> 18    {
> 19            init(windowNibName: "foo", owner: self); 
> 20    }

Re-reading the Swift book to research my answers in this thread, I found this:

> “If your subclass provides an implementation of all of its 
> superclass-designated initializers—either by inheriting them as per rule 1, 
> or […] — then it automatically inherits all of the superclass convenience 
> initializers.”

According to that, your original attempt should have worked, but it didn’t 
because of a wrinkle:

> “[I]f you write a subclass initializer that matches a superclass convenience 
> initializer, that superclass convenience initializer can never be called 
> directly by your subclass […]. Therefore, you don not write the override 
> modifier when providing a matching implementation of a superclass convenience 
> initializer.”

In short, take the “override” keyword off your declaration, and it should work 
exactly as you expected. (!)



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to