Actually, you can do this in Swift using protocol extensions:
Create a protocol and define the desired variable using getter:
protocol Order { var MAX_ORDER_ITEMS: Int { get } func getItem(item: Int) -> OrderItem
Define the protocol extension:
extension Order { var MAX_ORDER_ITEMS: Int { return 1000 } }
The advantage of this is that you do not need a protocol name prefix, as usual, with Swift and statics.
The only problems are that you can only access the variable from the class that implements the protocol (this is probably the most common case).
source share