[Tip] Swift -> Protocol Conditional Extension

protocol MyProtocol {

}

extension MyProtocol where Self: ImmutableMappable {
static func createObject() -> [Self]  {
var items = [Self]()
var json: [String: Any] = [“greeting”: “hello world”]
let item = self.init(JSON: json)
items.append(item)

return items
}

}

 

https://stackoverflow.com/questions/35133887/how-to-require-that-a-protocol-can-only-be-adopted-by-a-specific-class