protocol Init {
init(data: [String: Any])
}
func httpGet<T: Init>(completion: (T) -> Void) {
let data: [String: Any] = ["x": "Awesome"]
completion(T(data: data))
}
struct Model: Init {
let x: String
init(data: [String: Any]) {
x = data["x"]! as! String
}
}
httpGet { (model: Model) in
}
Comments