class - Swift. Use extended property type in subclass -


i need extended property in subclass, code doesn't compile.

protocol { } protocol b: { } protocol c: { }  class base {     var presenter: a? } class left: base {     override var presenter: b? } class right: base {     override var presenter: c? } 

how implement on swift 2?

you can't override or change property type in swift, casting might you. check left class in code example:

protocol { } protocol b: { } protocol c: { }  class base {     var presenter: a? }   class left: base {      init(persenter : b?) {         self.presenter = presenter     }      func test() {         print(presenter as! b)     } }  class right: base {     var presenter: c?  //won't compile } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -