Protocols in Swift - Part 1
So I got something wrong - the next course in my 'Beginner IOS' track is Protocols, not making an app! Not sure how that happened. Anyway, I'm not sure what Protocols are, but I assume it's do with more complex methods. Here we go.... What is a Protocol? Pasan uses the coffee shop example. The concept is to define a blueprint of methods, properties and other behaviours. Expected behaviours. protocol FullNameable { var fullName: String { get } } So that's the syntax for protocols. Whatever uses this protocol must use the fullName property and apparently it is 'gettable'. Not sure what that means...yet.... OK, we can read the property but not set it until we get an initial value....still not clear! Creating a Protocol struct U ser: FullNameable { } An error comes up here as I have not put in the necessary properties. struct User: FullNameable { var ful...