Skip to content

Instantly share code, notes, and snippets.

@alperenarc
Created May 11, 2021 12:20
Show Gist options
  • Save alperenarc/f2093ec1d881848b6108a8f888757cc3 to your computer and use it in GitHub Desktop.
Save alperenarc/f2093ec1d881848b6108a8f888757cc3 to your computer and use it in GitHub Desktop.
Protocol
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