April 2017
Intermediate to advanced
316 pages
9h 33m
English
First, we need to define a protocol for our request models:
protocol RequestProtocol { subscript(key: String) -> (String?, String?) { get } } extension RequestProtocol { func getPropertyNames()-> [String] { return Mirror(reflecting: self).children.filter { $0.label != nil }.map { $0.label! } } }
Here, we defined a protocol and we extended the protocol to be able to reflect the object and get properties and their values.
Also, we added a subscript to our protocol, which any struct that wants to conform to this protocol should implement.
Read now
Unlock full access