Here's an example of a protocol in Swift that includes an enum variable:
main.swift687 chars38 lines
In this example, the Transportation
protocol includes a variable called mode
of type Mode
. Classes that adopt the Transportation
protocol must implement the mode
variable and the start()
method.
Each class that adopts the Transportation
protocol can set a default mode
using the enum
values defined in the Mode
enum.
gistlibby LogSnag