Advertisement
Revolucent

Untitled

Sep 8th, 2017
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.34 KB | None | 0 0
  1. protocol Init {
  2.     init(data: [String: Any])
  3. }
  4.  
  5. func httpGet<T: Init>(completion: (T) -> Void) {
  6.     let data: [String: Any] = ["x": "Awesome"]
  7.     completion(T(data: data))
  8. }
  9.  
  10. struct Model: Init {
  11.     let x: String
  12.     init(data: [String: Any]) {
  13.         x = data["x"]! as! String
  14.     }
  15. }
  16.  
  17. httpGet { (model: Model) in
  18.    
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement