Skip to content

Commit 4e77f0b

Browse files
author
Pinglin Tang
committed
Merge pull request #30 from jregnauld/swift-2.0
Fixing responseSwiftyJSON because Alamofire returns ErrorType instead of NSError
2 parents cf3e638 + ce3abd7 commit 4e77f0b

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ source 'https://github.com/CocoaPods/Specs.git'
1414
platform :ios, '8.0'
1515
use_frameworks!
1616
17-
pod 'Alamofire', :git => 'https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git', :branch => 'swift-2.0'
17+
pod 'Alamofire-SwiftyJSON'
18+
1819
```
1920

2021
## Usage

Source/Alamofire-SwiftyJSON.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension Request {
2222

2323
:returns: The request.
2424
*/
25-
public func responseSwiftyJSON(completionHandler: (NSURLRequest, NSHTTPURLResponse?, SwiftyJSON.JSON, NSError?) -> Void) -> Self {
25+
public func responseSwiftyJSON(completionHandler: (NSURLRequest, NSHTTPURLResponse?, SwiftyJSON.JSON, ErrorType?) -> Void) -> Self {
2626
return responseSwiftyJSON(nil, options:NSJSONReadingOptions.AllowFragments, completionHandler:completionHandler)
2727
}
2828

@@ -35,7 +35,7 @@ extension Request {
3535

3636
:returns: The request.
3737
*/
38-
public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, NSError?) -> Void) -> Self {
38+
public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, ErrorType?) -> Void) -> Self {
3939

4040
return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (request, response, result) -> Void in
4141
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {

Tests/Alamofire_SwiftyJSONTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Alamofire_SwiftyJSONTests: XCTestCase {
2222
expectation.fulfill()
2323
XCTAssertNotNil(request, "request should not be nil")
2424
XCTAssertNotNil(response, "response should not be nil")
25-
XCTAssertNil(error, "error should be nil")
25+
XCTAssertTrue(error == nil, "result error should be nil")
2626
XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
2727
})
2828
waitForExpectationsWithTimeout(10) { (error) in

0 commit comments

Comments
 (0)