diff --git a/AlamofireObjectMapper/AlamofireObjectMapper.swift b/AlamofireObjectMapper/AlamofireObjectMapper.swift index 6dc539b..56ad121 100644 --- a/AlamofireObjectMapper/AlamofireObjectMapper.swift +++ b/AlamofireObjectMapper/AlamofireObjectMapper.swift @@ -109,7 +109,7 @@ extension DataRequest { let JSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath) if let JSONObject = JSONObject, - let parsedObject = (try? Mapper(context: context, shouldIncludeNilValues: false).map(JSONObject: JSONObject)){ + let parsedObject = (try? Mapper(context: context, shouldIncludeNilValues: false).map(JSONObject: JSONObject) as T) { return parsedObject } else { let failureReason = "ObjectMapper failed to serialize response." @@ -129,12 +129,12 @@ extension DataRequest { - returns: The request. */ @discardableResult - public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse) -> Void) -> Self { + public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperSerializer(keyPath, mapToObject: object, context: context), completionHandler: completionHandler) } @discardableResult - public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse) -> Void) -> Self { + public func responseObject(queue: DispatchQueue = .main, keyPath: String? = nil, mapToObject object: T? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperImmutableSerializer(keyPath, context: context), completionHandler: completionHandler) } @@ -165,7 +165,7 @@ extension DataRequest { if let JSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath){ - if let parsedObject = try? Mapper(context: context, shouldIncludeNilValues: false).mapArray(JSONObject: JSONObject){ + if let parsedObject = try? Mapper(context: context, shouldIncludeNilValues: false).mapArray(JSONObject: JSONObject) as [T] { return parsedObject } } @@ -185,7 +185,7 @@ extension DataRequest { - returns: The request. */ @discardableResult - public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse<[T]>) -> Void) -> Self { + public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse<[T]>) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperArraySerializer(keyPath, context: context), completionHandler: completionHandler) } @@ -199,7 +199,7 @@ extension DataRequest { - returns: The request. */ @discardableResult - public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (DataResponse<[T]>) -> Void) -> Self { + public func responseArray(queue: DispatchQueue = .main, keyPath: String? = nil, context: MapContext? = nil, completionHandler: @escaping (AFDataResponse<[T]>) -> Void) -> Self { return response(queue: queue, responseSerializer: DataRequest.ObjectMapperImmutableArraySerializer(keyPath, context: context), completionHandler: completionHandler) } } diff --git a/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift b/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift index 1a06fc9..ae877b2 100644 --- a/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift +++ b/AlamofireObjectMapperTests/AlamofireObjectMapperTests.swift @@ -49,10 +49,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -78,10 +78,10 @@ class AlamofireObjectMapperTests: XCTestCase { let weatherResponse = WeatherResponse() weatherResponse.date = Date() - _ = Alamofire.request(URL, method: .get).responseObject(mapToObject: weatherResponse) { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject(mapToObject: weatherResponse) { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value print(weatherResponse) XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.date, "Date should not be nil") // Date is not in JSON but should not be nil because we mapped onto an existing object with a date set @@ -105,10 +105,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/2ee8f34d21e8febfdefb2b3a403f18a43818d70a/sample_keypath_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject(keyPath: "data") { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject(keyPath: "data") { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -131,10 +131,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/97231a04e6e4970612efcc0b7e0c125a83e3de6e/sample_keypath_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject(keyPath: "response.data") { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject(keyPath: "response.data") { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -157,10 +157,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/f583be1121dbc5e9b0381b3017718a70c31054f7/sample_array_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray { (response: DataResponse<[Forecast]>) in + _ = AF.request(URL, method: .get).responseArray { (response: AFDataResponse<[Forecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") @@ -183,11 +183,11 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray(keyPath: "three_day_forecast") { (response: DataResponse<[Forecast]>) in + _ = AF.request(URL, method: .get).responseArray(keyPath: "three_day_forecast") { (response: AFDataResponse<[Forecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") @@ -208,11 +208,11 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/97231a04e6e4970612efcc0b7e0c125a83e3de6e/sample_keypath_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray(keyPath: "response.data.three_day_forecast") { (response: DataResponse<[Forecast]>) in + _ = AF.request(URL, method: .get).responseArray(keyPath: "response.data.three_day_forecast") { (response: AFDataResponse<[Forecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") @@ -235,10 +235,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseObject { (response: DataResponse) in + _ = AF.request(URL, method: .get).responseObject { (response: AFDataResponse) in expectation.fulfill() - let mappedObject = response.result.value + let mappedObject = response.value XCTAssertNotNil(mappedObject, "Response should not be nil") XCTAssertNotNil(mappedObject?.location, "Location should not be nil") @@ -261,10 +261,10 @@ class AlamofireObjectMapperTests: XCTestCase { let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/f583be1121dbc5e9b0381b3017718a70c31054f7/sample_array_json" let expectation = self.expectation(description: "\(URL)") - _ = Alamofire.request(URL, method: .get).responseArray { (response: DataResponse<[ImmutableForecast]>) in + _ = AF.request(URL, method: .get).responseArray { (response: AFDataResponse<[ImmutableForecast]>) in expectation.fulfill() - let mappedArray = response.result.value + let mappedArray = response.value XCTAssertNotNil(mappedArray, "Response should not be nil") diff --git a/Cartfile b/Cartfile index b88c036..444b0a7 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "Alamofire/Alamofire" "5.0.0-beta.6" -github "tristanhimmelman/ObjectMapper" ~> 3.4 +github "Alamofire/Alamofire" "5.0.0-rc.2" +github "tristanhimmelman/ObjectMapper" ~> 3.5.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 7bb1668..8ada0d1 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Alamofire/Alamofire" "5.0.0-beta.6" +github "Alamofire/Alamofire" "5.0.0-rc.2" github "tristanhimmelman/ObjectMapper" "3.5.1"