Created
June 30, 2015 22:03
-
-
Save somegeekintn/32cb4d335ae3244f33dc to your computer and use it in GitHub Desktop.
Why does line 19 trigger didSet on stringProto?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol StringProto { | |
var string: String? { get set } | |
} | |
class StringClass : StringProto { | |
var string : String? = "" | |
} | |
class SetterTest { | |
var stringProto: StringProto? { | |
didSet { | |
println("didSet") | |
self.initStringVal() | |
} | |
} | |
func initStringVal() { | |
println("initStringVal") | |
test.stringProto?.string = "init value" | |
} | |
} | |
var test = SetterTest() | |
test.stringProto = StringClass() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, can have
StringProto
inherit fromclass