Revolucent icon

Untitled

Revolucent | PRO | 09/09/17 02:11:01 AM UTC | 0 ⭐ | 1234 👁️ | Never ⏰ | []
Swift |

340 B

|

None

|

0 👍

/

0 👎

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