O'Reilly logo

Swift 3 ObjectOriented Programming - Second Edition by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declaring protocols

Now, it is time to code the protocols in Swift. We will code the following five protocols:

  • ComicCharacter
  • GameCharacter
  • Alien
  • Wizard
  • Knight

The following UML diagram shows the five protocols that we will code in Swift, with their required properties and methods included in the diagram. In this case, the diagram shows only protocols and we don't use any mark above the protocol name. However, in other diagrams in which we will mix protocols with classes, we will add procotol after the protocol name. UML diagrams have specifications for interfaces, but we will use our own mechanism to identify protocols:

Declaring protocols

The following lines show the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required