Re: Subclassing NSWindowController in Swift
Re: Subclassing NSWindowController in Swift
- Subject: Re: Subclassing NSWindowController in Swift
- From: Rick Mann <email@hidden>
- Date: Sun, 19 Oct 2014 00:24:35 -0700
> On Oct 19, 2014, at 00:19 , Quincey Morris <email@hidden> wrote:
>
> On Oct 18, 2014, at 23:46 , Rick Mann <email@hidden> wrote:
>>
>> The rules on initializers don't make sense to me, in all honesty.
>
> Yes, but that tells us more about you than about Swift — specifically, it tells us that you’re more focused on what would ease your coding task in this one case than on embracing more formal relationships between initializers. Understandable, but not really useful to anyone else, if you’ll forgive my saying so.
>
>> If you imagine that instantiating the base class by calling any of the initializers results in a completely instantiated object, the subclass should also be able to call any of the inherited initializers.
>
> Yes, but …
>
> (It’s all about the “yes, but”s.)
>
> … calling *up* from a subclass convenience initializer bypasses all of the subclass designated initializers (except in the case that the subclass overrides some or all of the superclass's, which introduces its own semantic ambiguities). That means that the subclass can’t be sure it initialized its own properties, since that’s the purview of designated initializers — at least not without supplementary rules. That in turn destroys the integrity of Swift’s 2-pass initialization process.
Well, I'm not sure I agree with that. Every initializer in a class should work correctly. An external caller can initialize a class by calling any of its init methods, why can't a subclass?
At the very least, NSWindowController's choice of designated initializer increases the burden on subclasses.
--
Rick Mann
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden