Skip to content

Commit cf3e638

Browse files
author
Pinglin Tang
committed
Merge pull request #29 from jregnauld/swift-2.0
Swift 2.0 #25
2 parents e9d4acd + 8cc2d83 commit cf3e638

7 files changed

Lines changed: 32 additions & 26 deletions

File tree

Alamofire

Submodule Alamofire updated 71 files

Alamofire-SwiftyJSON.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Alamofire-SwiftyJSON"
3-
s.version = "1.1.0"
3+
s.version = "2.0.0-beta.1"
44
s.summary = "Alamofire extension for serialize NSData to SwiftyJSON "
55
s.homepage = "https://github.com/SwiftyJSON/Alamofire-SwiftyJSON"
66
s.license = { :type => "MIT" }
@@ -9,6 +9,6 @@ Pod::Spec.new do |s|
99
s.requires_arc = true
1010
s.osx.deployment_target = "10.9"
1111
s.ios.deployment_target = "8.0"
12-
s.source = { :git => "https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git", :tag => "1.1.0"}
12+
s.source = { :git => "https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git", :tag => s.version }
1313
s.source_files = "Source/*.swift"
1414
end

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ Easy way to use both [Alamofire](https://github.com/Alamofire/Alamofire) and [Sw
44

55
## Requirements
66

7-
- iOS 7.0+ / Mac OS X 10.9+
8-
- Xcode 6.1
7+
- iOS 8.0+ / Mac OS X 10.9+
8+
- Xcode 7.0
9+
10+
## Install
11+
12+
```
13+
source 'https://github.com/CocoaPods/Specs.git'
14+
platform :ios, '8.0'
15+
use_frameworks!
16+
17+
pod 'Alamofire', :git => 'https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git', :branch => 'swift-2.0'
18+
```
919

1020
## Usage
1121

Source/Alamofire-SwiftyJSON.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension Request {
2323
:returns: The request.
2424
*/
2525
public func responseSwiftyJSON(completionHandler: (NSURLRequest, NSHTTPURLResponse?, SwiftyJSON.JSON, NSError?) -> Void) -> Self {
26-
return responseSwiftyJSON(queue:nil, options:NSJSONReadingOptions.AllowFragments, completionHandler:completionHandler)
26+
return responseSwiftyJSON(nil, options:NSJSONReadingOptions.AllowFragments, completionHandler:completionHandler)
2727
}
2828

2929
/**
@@ -37,19 +37,17 @@ extension Request {
3737
*/
3838
public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, NSError?) -> Void) -> Self {
3939

40-
return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (request, response, object, error) -> Void in
41-
40+
return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (request, response, result) -> Void in
4241
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
43-
4442
var responseJSON: JSON
45-
if error != nil || object == nil{
46-
responseJSON = JSON.nullJSON
43+
if result.isFailure
44+
{
45+
responseJSON = JSON.null
4746
} else {
48-
responseJSON = SwiftyJSON.JSON(object!)
47+
responseJSON = SwiftyJSON.JSON(result.value!)
4948
}
50-
5149
dispatch_async(queue ?? dispatch_get_main_queue(), {
52-
completionHandler(self.request, self.response, responseJSON, error)
50+
completionHandler(self.request!, self.response, responseJSON, result.error)
5351
})
5452
})
5553
})

Source/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>2.0.0-beta.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

SwiftyJSON

Tests/Alamofire_SwiftyJSONTests.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ class Alamofire_SwiftyJSONTests: XCTestCase {
1717
func testJSONResponse() {
1818
let URL = "http://httpbin.org/get"
1919
let expectation = expectationWithDescription("\(URL)")
20-
21-
Alamofire.request(.GET, URL, parameters: ["foo": "bar"])
22-
.responseSwiftyJSON { (request, response, responseJSON, error) in
23-
expectation.fulfill()
24-
XCTAssertNotNil(request, "request should not be nil")
25-
XCTAssertNotNil(response, "response should not be nil")
26-
XCTAssertNil(error, "error should be nil")
27-
XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
28-
}
29-
20+
21+
Alamofire.request(.GET, URL, parameters: ["foo": "bar"]).responseSwiftyJSON({(request, response, responseJSON, error) in
22+
expectation.fulfill()
23+
XCTAssertNotNil(request, "request should not be nil")
24+
XCTAssertNotNil(response, "response should not be nil")
25+
XCTAssertNil(error, "error should be nil")
26+
XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
27+
})
3028
waitForExpectationsWithTimeout(10) { (error) in
3129
XCTAssertNil(error, "\(error)")
3230
}

0 commit comments

Comments
 (0)