Created
March 24, 2018 08:02
-
-
Save reddioment/95256b5ace68506ed704c85c74e60ccd to your computer and use it in GitHub Desktop.
init-class-subclass-overriding-designated,conveniance
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
class SomeClass { | |
var str: String | |
init(str: String) { | |
self.str = str | |
} | |
convenience init(strFromInt num: Int) { | |
self.init(str: "\(num)") | |
} | |
} | |
class AnotherClass: SomeClass { | |
var text: String | |
init(text: String, str: String) { | |
self.text = text | |
super.init(str: str) | |
} | |
override init(str: String) { | |
self.text = str | |
super.init(str: str) | |
} | |
convenience init(strFromInt num: Int) { | |
self.init(str: "\(num)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment