April 2017
Intermediate to advanced
316 pages
9h 33m
English
Any protocol that we define will become a fully-fledged type to use in our code. We can use a protocol as follows:
Let's look at the following example:
protocol ExampleProtocol { var simpleDescription: String { get } mutating func adjust() } // Classes, enumerations and structs can all adopt protocols. class SimpleClass: ExampleProtocol { var simpleDescription: String = "A very simple class example" var anotherProperty: Int = 79799 func adjust() { simpleDescription += "Now 100% adjusted..." } } var aSimpleClass = SimpleClass() aSimpleClass.adjust() ...Read now
Unlock full access