Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public func get<T: Mappable>(type: String, id: Int, completion: @escaping (_ success: Bool, _ value: T?) -> Void) {
- //... part where the requestURLString, user and password are declared
- Alamofire.request(requestURLString)
- .authenticate(user: user, password: password)
- .responseJSON { response in
- if response.result.isSuccess {
- let object = Mapper<T>().map(response.result.value![type])
- completion(success: true, value: object)
- } else {
- completion(false, nil)
- }
- }
- }
- let object = Mapper<T>().map(response.result.value![type])
Add Comment
Please, Sign In to add comment