Guest User

Untitled

a guest
Feb 9th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public func get<T: Mappable>(type: String, id: Int, completion: @escaping (_ success: Bool, _ value: T?) -> Void) {
  2. //... part where the requestURLString, user and password are declared
  3.  
  4. Alamofire.request(requestURLString)
  5. .authenticate(user: user, password: password)
  6. .responseJSON { response in
  7. if response.result.isSuccess {
  8. let object = Mapper<T>().map(response.result.value![type])
  9. completion(success: true, value: object)
  10. } else {
  11. completion(false, nil)
  12. }
  13. }
  14. }
  15.  
  16. let object = Mapper<T>().map(response.result.value![type])
Add Comment
Please, Sign In to add comment