• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Init in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Init in Swift


  • Subject: Re: Init in Swift
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 06 Sep 2016 20:49:34 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sNOOIIdVds:SMTPCORP

On Sep 6, 2016, at 17:17 , Gerriet M. Denkmann <email@hidden> wrote:
>
> But what to do about localConstantDependingOnSuper?

Now you’re moving the goal posts. :) I said:

> assuming the places of definition aren’t more complicated than in your code

and you’re making it more complicated. Anyway, this particular example is fairly easily solved by declaring “localConstantDependingOnSuper” as ‘private(set)’.

> I do not think this would work for me. There are several subclasses and the superclass contains lots of functions (some of which are overwritten by subclasses).
> If the superclass becomes a protocol then all this code had to be duplicated in each subclass.
>
>
> Another problem:
> Super → SubA and SubB.
> SubA → SubA1 and SubA2
> SubB → SubB1 and SubB2
>
> Both SubA1 and SubB1 have identical functions. As have  SubA2 and SubB2.
> Multiple inheritance would be a solution here; but neither Objective-C nor Swift can do this (and I don’t like C++).

There’s not necessarily a straightforward conversion from subclassing to protocol composition. It usually takes some fundamental re-thinking of your approach to to the problem.

_______________________________________________

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


  • Follow-Ups:
    • Re: Init in Swift
      • From: "Gerriet M. Denkmann" <email@hidden>
    • Re: Init in Swift
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >Init in Swift (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Init in Swift (From: Quincey Morris <email@hidden>)
 >Re: Init in Swift (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: slicing in Swift
  • Next by Date: Security-scoped bookmarks, what's going on?
  • Previous by thread: Re: Init in Swift
  • Next by thread: Re: Init in Swift
  • Index(es):
    • Date
    • Thread