Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions AlamofireAdapter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
3F0F00091E54B9C10073ED3B /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F9DB0EB1C8F229C00D41C26 /* Alamofire.framework */; };
3F0F000A1E54B9C40073ED3B /* APIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F9DB0ED1C8F229C00D41C26 /* APIKit.framework */; };
3F0F000B1E54B9C70073ED3B /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F9DB0EF1C8F229C00D41C26 /* Result.framework */; };
7F5669DE1C8F215300F37D3D /* AlamofireAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F5669DD1C8F215300F37D3D /* AlamofireAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
7F9DB37A1C8F229C00D41C26 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F9DB0EB1C8F229C00D41C26 /* Alamofire.framework */; };
7F9DB37C1C8F229D00D41C26 /* APIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F9DB0ED1C8F229C00D41C26 /* APIKit.framework */; };
7F9DB37E1C8F229D00D41C26 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F9DB0EF1C8F229C00D41C26 /* Result.framework */; };
7F9DB6021C8F22DA00D41C26 /* AlamofireAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F9DB6011C8F22DA00D41C26 /* AlamofireAdapter.swift */; };
7FAC40221C8F28970098C4B2 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FAC40211C8F28970098C4B2 /* Tests.swift */; };
7FAC40241C8F28970098C4B2 /* AlamofireAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F5669DA1C8F215300F37D3D /* AlamofireAdapter.framework */; };
Expand Down Expand Up @@ -65,9 +65,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7F9DB37E1C8F229D00D41C26 /* Result.framework in Frameworks */,
7F9DB37C1C8F229D00D41C26 /* APIKit.framework in Frameworks */,
7F9DB37A1C8F229C00D41C26 /* Alamofire.framework in Frameworks */,
3F0F00091E54B9C10073ED3B /* Alamofire.framework in Frameworks */,
3F0F000A1E54B9C40073ED3B /* APIKit.framework in Frameworks */,
3F0F000B1E54B9C70073ED3B /* Result.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -212,6 +212,7 @@
TargetAttributes = {
7F5669D91C8F215300F37D3D = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0820;
};
7FAC401E1C8F28970098C4B2 = {
CreatedOnToolsVersion = 7.2.1;
Expand Down Expand Up @@ -405,6 +406,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand Down Expand Up @@ -441,6 +443,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "-.AlamofireAdapter";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down Expand Up @@ -500,6 +503,7 @@
7FAC40291C8F28970098C4B2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
18 changes: 9 additions & 9 deletions AlamofireAdapter/AlamofireAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import Foundation
import Alamofire
import APIKit

public class AlamofireAdapter: SessionAdapterType {
public let manager: Alamofire.Manager
open class AlamofireAdapter: SessionAdapter {
open let manager: Alamofire.SessionManager

public init(manager: Alamofire.Manager) {
public init(manager: Alamofire.SessionManager) {
self.manager = manager
}

public func createTaskWithURLRequest(URLRequest: NSURLRequest, handler: (NSData?, NSURLResponse?, ErrorType?) -> Void) -> SessionTaskType {
public func createTask(with URLRequest: URLRequest, handler: @escaping (Data?, URLResponse?, Error?) -> Void) -> SessionTask {
let request = manager.request(URLRequest)

request.responseData { response in
handler(response.data, response.response, response.result.error)
}

return request.task
return request.task!
}

public func getTasksWithHandler(handler: [SessionTaskType] -> Void) {
public func getTasks(with handler: @escaping ([SessionTask]) -> Void) {
manager.session.getTasksWithCompletionHandler { dataTasks, uploadTasks, downloadTasks in
let allTasks = dataTasks as [NSURLSessionTask]
+ uploadTasks as [NSURLSessionTask]
+ downloadTasks as [NSURLSessionTask]
let allTasks = dataTasks as [URLSessionTask]
+ uploadTasks as [URLSessionTask]
+ downloadTasks as [URLSessionTask]

handler(allTasks.map { $0 })
}
Expand Down
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "ishkawa/APIKit" ~> 2.0.0
github "Alamofire/Alamofire" ~> 3.2.1
github "ishkawa/APIKit" ~> 3.0
github "Alamofire/Alamofire" ~> 4.3
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Alamofire/Alamofire" "3.4.0"
github "antitypical/Result" "2.0.0"
github "ishkawa/APIKit" "2.0.0-beta.7"
github "Alamofire/Alamofire" "4.3.0"
github "antitypical/Result" "3.1.0"
github "ishkawa/APIKit" "3.1.2"