From 02c5276e39fd8e57e80f05f60407045b0c5f5db3 Mon Sep 17 00:00:00 2001 From: Sua Le Date: Tue, 21 Aug 2018 13:41:11 +0700 Subject: [PATCH] - update example --- Example/Example/ViewController.swift | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 77340b1..f2b1b7e 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -15,7 +15,8 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() //default key - Alamofire.request("https://reqres.in/api/users", method: .get + let url1 = "https://raw.githubusercontent.com/sua8051/AlamofireMapper/master/user1.json" + Alamofire.request(url1, method: .get , parameters: nil, encoding: URLEncoding.default, headers: nil).responseObject { (response: DataResponse) in switch response.result { case let .success(data): @@ -26,9 +27,9 @@ class ViewController: UIViewController { } //custom coding key - let params: [String: Any] = ["name": "paul rudd", "movies": ["I Love You Man", "Role Models"]] - Alamofire.request("https://reqres.in/api/users", method: .post - , parameters: params, encoding: URLEncoding.default, headers: nil).responseObject { (response: DataResponse) in + let url2 = "https://raw.githubusercontent.com/sua8051/AlamofireMapper/master/movie.json" + Alamofire.request(url2, method: .get + , parameters: nil, encoding: URLEncoding.default, headers: nil).responseObject { (response: DataResponse) in switch response.result { case let .success(data): dump(data) @@ -37,6 +38,17 @@ class ViewController: UIViewController { } } + //response array + let url3 = "https://raw.githubusercontent.com/sua8051/AlamofireMapper/master/user2.json" + Alamofire.request(url3, method: .get + , parameters: nil, encoding: URLEncoding.default, headers: nil).responseObject { (response: DataResponse<[User]>) in + switch response.result { + case let .success(data): + dump(data) + case let .failure(error): + dump(error) + } + } // Do any additional setup after loading the view, typically from a nib. }