Created
May 11, 2021 12:20
-
-
Save alperenarc/f2093ec1d881848b6108a8f888757cc3 to your computer and use it in GitHub Desktop.
Protocol
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 MyPerson { | |
var name: String { get set } | |
static var surname: String { get set } | |
init(name: String) | |
func printMyName() | |
} | |
extension MyPerson { | |
func myOptionalFunction() { | |
print("Does not have to be overridden (From Protocol)") | |
} | |
} | |
class MyController: MyPerson { | |
static var surname: String = "Arıcı" | |
var name: String | |
required init(name: String) { | |
self.name = name | |
} | |
func printMyName() { | |
print("Print from MyController") | |
} | |
} | |
let myControllerInstance = MyController(name: "Alperen") | |
print(myControllerInstance.name) | |
print(MyController.surname) | |
myControllerInstance.myOptionalFunction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment