Skip to content

Commit 8cb1e13

Browse files
committed
Fixes #35, Update response for Alamofire 3. completionHandler returns a Response struct instead of request, response, result.
1 parent c43bba8 commit 8cb1e13

3 files changed

Lines changed: 128 additions & 27 deletions

File tree

Alamofire-SwiftyJSON.xcodeproj/project.pbxproj

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,47 @@
1818
/* End PBXBuildFile section */
1919

2020
/* Begin PBXContainerItemProxy section */
21-
A8A2DBB21A2328F500AF9EFC /* PBXContainerItemProxy */ = {
21+
4BC5E9F91BB7E15600A393DD /* PBXContainerItemProxy */ = {
22+
isa = PBXContainerItemProxy;
23+
containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */;
24+
proxyType = 2;
25+
remoteGlobalIDString = 4DD67C0B1A5C55C900ED2280;
26+
remoteInfo = "Alamofire OSX";
27+
};
28+
4BC5E9FB1BB7E15600A393DD /* PBXContainerItemProxy */ = {
29+
isa = PBXContainerItemProxy;
30+
containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */;
31+
proxyType = 2;
32+
remoteGlobalIDString = E4202FE01B667AA100C997FB;
33+
remoteInfo = "Alamofire watchOS";
34+
};
35+
4BC5E9FD1BB7E15600A393DD /* PBXContainerItemProxy */ = {
36+
isa = PBXContainerItemProxy;
37+
containerPortal = A8AFB75419D14A5C0070765E /* Alamofire.xcodeproj */;
38+
proxyType = 2;
39+
remoteGlobalIDString = F829C6B21A7A94F100A2CD59;
40+
remoteInfo = "Alamofire OSX Tests";
41+
};
42+
4BC5EA031BB7E15600A393DD /* PBXContainerItemProxy */ = {
2243
isa = PBXContainerItemProxy;
2344
containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */;
2445
proxyType = 2;
25-
remoteGlobalIDString = 4EC1C1C91A0C1A2D0026ED0B;
26-
remoteInfo = SwiftyJSONOSX;
46+
remoteGlobalIDString = 9C7DFC5B1A9102BD005AA3F7;
47+
remoteInfo = "SwiftyJSON OSX";
2748
};
28-
A8A2DBB41A2328F500AF9EFC /* PBXContainerItemProxy */ = {
49+
4BC5EA051BB7E15600A393DD /* PBXContainerItemProxy */ = {
2950
isa = PBXContainerItemProxy;
3051
containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */;
3152
proxyType = 2;
32-
remoteGlobalIDString = 4EC1C1D31A0C1A2D0026ED0B;
33-
remoteInfo = SwiftyJSONOSXTests;
53+
remoteGlobalIDString = 9C7DFC651A9102BD005AA3F7;
54+
remoteInfo = "SwiftyJSON OSX Tests";
55+
};
56+
4BC5EA071BB7E15600A393DD /* PBXContainerItemProxy */ = {
57+
isa = PBXContainerItemProxy;
58+
containerPortal = A8AFB75D19D14A670070765E /* SwiftyJSON.xcodeproj */;
59+
proxyType = 2;
60+
remoteGlobalIDString = E4D7CCE81B9465A700EE7221;
61+
remoteInfo = "SwiftyJSON watchOS";
3462
};
3563
A8A2DBB61A23290100AF9EFC /* PBXContainerItemProxy */ = {
3664
isa = PBXContainerItemProxy;
@@ -214,7 +242,10 @@
214242
isa = PBXGroup;
215243
children = (
216244
A8AFB75A19D14A5C0070765E /* Alamofire.framework */,
245+
4BC5E9FA1BB7E15600A393DD /* Alamofire.framework */,
246+
4BC5E9FC1BB7E15600A393DD /* Alamofire.framework */,
217247
A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */,
248+
4BC5E9FE1BB7E15600A393DD /* Alamofire OSX Tests.xctest */,
218249
);
219250
name = Products;
220251
sourceTree = "<group>";
@@ -224,8 +255,9 @@
224255
children = (
225256
A8AFB76519D14A670070765E /* SwiftyJSON.framework */,
226257
A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */,
227-
A8A2DBB31A2328F500AF9EFC /* SwiftyJSON.framework */,
228-
A8A2DBB51A2328F500AF9EFC /* SwiftyJSONOSXTests.xctest */,
258+
4BC5EA041BB7E15600A393DD /* SwiftyJSON.framework */,
259+
4BC5EA061BB7E15600A393DD /* SwiftyJSON OSX Tests.xctest */,
260+
4BC5EA081BB7E15600A393DD /* SwiftyJSON.framework */,
229261
);
230262
name = Products;
231263
sourceTree = "<group>";
@@ -292,6 +324,7 @@
292324
A8AFB70619D1401D0070765E /* Project object */ = {
293325
isa = PBXProject;
294326
attributes = {
327+
LastSwiftUpdateCheck = 0700;
295328
LastUpgradeCheck = 0600;
296329
ORGANIZATIONNAME = SwiftJSON;
297330
TargetAttributes = {
@@ -332,18 +365,46 @@
332365
/* End PBXProject section */
333366

334367
/* Begin PBXReferenceProxy section */
335-
A8A2DBB31A2328F500AF9EFC /* SwiftyJSON.framework */ = {
368+
4BC5E9FA1BB7E15600A393DD /* Alamofire.framework */ = {
369+
isa = PBXReferenceProxy;
370+
fileType = wrapper.framework;
371+
path = Alamofire.framework;
372+
remoteRef = 4BC5E9F91BB7E15600A393DD /* PBXContainerItemProxy */;
373+
sourceTree = BUILT_PRODUCTS_DIR;
374+
};
375+
4BC5E9FC1BB7E15600A393DD /* Alamofire.framework */ = {
376+
isa = PBXReferenceProxy;
377+
fileType = wrapper.framework;
378+
path = Alamofire.framework;
379+
remoteRef = 4BC5E9FB1BB7E15600A393DD /* PBXContainerItemProxy */;
380+
sourceTree = BUILT_PRODUCTS_DIR;
381+
};
382+
4BC5E9FE1BB7E15600A393DD /* Alamofire OSX Tests.xctest */ = {
383+
isa = PBXReferenceProxy;
384+
fileType = wrapper.cfbundle;
385+
path = "Alamofire OSX Tests.xctest";
386+
remoteRef = 4BC5E9FD1BB7E15600A393DD /* PBXContainerItemProxy */;
387+
sourceTree = BUILT_PRODUCTS_DIR;
388+
};
389+
4BC5EA041BB7E15600A393DD /* SwiftyJSON.framework */ = {
336390
isa = PBXReferenceProxy;
337391
fileType = wrapper.framework;
338392
path = SwiftyJSON.framework;
339-
remoteRef = A8A2DBB21A2328F500AF9EFC /* PBXContainerItemProxy */;
393+
remoteRef = 4BC5EA031BB7E15600A393DD /* PBXContainerItemProxy */;
340394
sourceTree = BUILT_PRODUCTS_DIR;
341395
};
342-
A8A2DBB51A2328F500AF9EFC /* SwiftyJSONOSXTests.xctest */ = {
396+
4BC5EA061BB7E15600A393DD /* SwiftyJSON OSX Tests.xctest */ = {
343397
isa = PBXReferenceProxy;
344398
fileType = wrapper.cfbundle;
345-
path = SwiftyJSONOSXTests.xctest;
346-
remoteRef = A8A2DBB41A2328F500AF9EFC /* PBXContainerItemProxy */;
399+
path = "SwiftyJSON OSX Tests.xctest";
400+
remoteRef = 4BC5EA051BB7E15600A393DD /* PBXContainerItemProxy */;
401+
sourceTree = BUILT_PRODUCTS_DIR;
402+
};
403+
4BC5EA081BB7E15600A393DD /* SwiftyJSON.framework */ = {
404+
isa = PBXReferenceProxy;
405+
fileType = wrapper.framework;
406+
path = SwiftyJSON.framework;
407+
remoteRef = 4BC5EA071BB7E15600A393DD /* PBXContainerItemProxy */;
347408
sourceTree = BUILT_PRODUCTS_DIR;
348409
};
349410
A8AFB75A19D14A5C0070765E /* Alamofire.framework */ = {
@@ -356,7 +417,7 @@
356417
A8AFB75C19D14A5C0070765E /* AlamofireTests.xctest */ = {
357418
isa = PBXReferenceProxy;
358419
fileType = wrapper.cfbundle;
359-
path = AlamofireTests.xctest;
420+
path = "Alamofire iOS Tests.xctest";
360421
remoteRef = A8AFB75B19D14A5C0070765E /* PBXContainerItemProxy */;
361422
sourceTree = BUILT_PRODUCTS_DIR;
362423
};
@@ -370,7 +431,7 @@
370431
A8AFB76719D14A670070765E /* SwiftyJSONTests.xctest */ = {
371432
isa = PBXReferenceProxy;
372433
fileType = wrapper.cfbundle;
373-
path = SwiftyJSONTests.xctest;
434+
path = "SwiftyJSON iOS Tests.xctest";
374435
remoteRef = A8AFB76619D14A670070765E /* PBXContainerItemProxy */;
375436
sourceTree = BUILT_PRODUCTS_DIR;
376437
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "79EA0C4F360E98830418AFAE1A03A39D646B0106",
3+
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4+
5+
},
6+
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7+
"67620B5EFA902936DF04070AF595B76AB0333747" : 0,
8+
"C861FC00CEE0F6A6BE81FCFF6785FAA78C58EBB3" : 0,
9+
"79EA0C4F360E98830418AFAE1A03A39D646B0106" : 0
10+
},
11+
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "91EDE7D1-24DF-4EB3-99E3-20EFE55617CE",
12+
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
13+
"67620B5EFA902936DF04070AF595B76AB0333747" : "Alamofire-SwiftyJSON\/Alamofire\/",
14+
"C861FC00CEE0F6A6BE81FCFF6785FAA78C58EBB3" : "Alamofire-SwiftyJSON\/SwiftyJSON\/",
15+
"79EA0C4F360E98830418AFAE1A03A39D646B0106" : "Alamofire-SwiftyJSON\/"
16+
},
17+
"DVTSourceControlWorkspaceBlueprintNameKey" : "Alamofire-SwiftyJSON",
18+
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
19+
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Alamofire-SwiftyJSON.xcodeproj",
20+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
21+
{
22+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Alamofire\/Alamofire.git",
23+
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
24+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "67620B5EFA902936DF04070AF595B76AB0333747"
25+
},
26+
{
27+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/jregnauld\/Alamofire-SwiftyJSON.git",
28+
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
29+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "79EA0C4F360E98830418AFAE1A03A39D646B0106"
30+
},
31+
{
32+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/SwiftyJSON\/SwiftyJSON.git",
33+
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
34+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C861FC00CEE0F6A6BE81FCFF6785FAA78C58EBB3"
35+
}
36+
]
37+
}

Source/Alamofire-SwiftyJSON.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,23 @@ extension Request {
3737
*/
3838
public func responseSwiftyJSON(queue: dispatch_queue_t? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: (NSURLRequest, NSHTTPURLResponse?, JSON, ErrorType?) -> Void) -> Self {
3939

40-
return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (request, response, result) -> Void in
41-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
42-
var responseJSON: JSON
43-
if result.isFailure
44-
{
45-
responseJSON = JSON.null
46-
} else {
47-
responseJSON = SwiftyJSON.JSON(result.value!)
48-
}
49-
dispatch_async(queue ?? dispatch_get_main_queue(), {
50-
completionHandler(self.request!, self.response, responseJSON, result.error)
40+
// With Alamofire 3, completionHandler returns a Response struct instead of request, response, result.
41+
//For more information about Response struct see: https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%203.0%20Migration%20Guide.md
42+
return response(queue: queue, responseSerializer: Request.JSONResponseSerializer(options: options), completionHandler: { (response) -> Void in
43+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
44+
var responseJSON: JSON
45+
if response.result.isFailure
46+
{
47+
responseJSON = JSON.null
48+
} else {
49+
responseJSON = SwiftyJSON.JSON(response.result.value!)
50+
}
51+
dispatch_async(queue ?? dispatch_get_main_queue(), {
52+
completionHandler(response.request!, response.response, responseJSON, response.result.error)
53+
})
5154
})
5255
})
53-
})
56+
5457
}
5558
}
5659

0 commit comments

Comments
 (0)