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
Post a Comment