mirror of
https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git
synced 2026-01-12 15:34:03 +08:00
Merge pull request #30 from jregnauld/swift-2.0
Fixing responseSwiftyJSON because Alamofire returns ErrorType instead of NSError
This commit is contained in:
Submodule Alamofire updated: 97531ad013...0fd77fec2a
@@ -14,7 +14,8 @@ source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
use_frameworks!
|
||||
|
||||
pod 'Alamofire', :git => 'https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git', :branch => 'swift-2.0'
|
||||
pod 'Alamofire-SwiftyJSON'
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -22,7 +22,7 @@ extension Request {
|
||||
|
||||
:returns: The request.
|
||||
*/
|
||||
public func responseSwiftyJSON(completionHandler: (NSURLRequest, NSHTTPURLResponse?, SwiftyJSON.JSON, NSError?) -> Void) -> Self {
|
||||
public func responseSwiftyJSON(completionHandler: (NSURLRequest, NSHTTPURLResponse?, SwiftyJSON.JSON, ErrorType?) -> Void) -> Self {
|
||||
return responseSwiftyJSON(nil, options:NSJSONReadingOptions.AllowFragments, completionHandler:completionHandler)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ extension Request {
|
||||
|
||||
:returns: The request.
|
||||
*/
|
||||
public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, NSError?) -> Void) -> Self {
|
||||
public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, ErrorType?) -> Void) -> Self {
|
||||
|
||||
return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (request, response, result) -> Void in
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
|
||||
|
||||
@@ -22,7 +22,7 @@ class Alamofire_SwiftyJSONTests: XCTestCase {
|
||||
expectation.fulfill()
|
||||
XCTAssertNotNil(request, "request should not be nil")
|
||||
XCTAssertNotNil(response, "response should not be nil")
|
||||
XCTAssertNil(error, "error should be nil")
|
||||
XCTAssertTrue(error == nil, "result error should be nil")
|
||||
XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
|
||||
})
|
||||
waitForExpectationsWithTimeout(10) { (error) in
|
||||
|
||||
Reference in New Issue
Block a user