Browse Source

Updates for the Xcode 8 GM.

Jon Shier 9 years ago
parent
commit
418b0fc16a

+ 5 - 5
Example/Source/MasterViewController.swift

@@ -66,23 +66,23 @@ class MasterViewController: UITableViewController {
                 switch segue.identifier! {
                 case "GET":
                     detailViewController.segueIdentifier = "GET"
-                    return Alamofire.request("https://httpbin.org/get", withMethod: .get)
+                    return Alamofire.request("https://httpbin.org/get")
                 case "POST":
                     detailViewController.segueIdentifier = "POST"
-                    return Alamofire.request("https://httpbin.org/post", withMethod: .post)
+                    return Alamofire.request("https://httpbin.org/post", method: .post)
                 case "PUT":
                     detailViewController.segueIdentifier = "PUT"
-                    return Alamofire.request("https://httpbin.org/put", withMethod: .put)
+                    return Alamofire.request("https://httpbin.org/put", method: .put)
                 case "DELETE":
                     detailViewController.segueIdentifier = "DELETE"
-                    return Alamofire.request("https://httpbin.org/delete", withMethod: .delete)
+                    return Alamofire.request("https://httpbin.org/delete", method: .delete)
                 case "DOWNLOAD":
                     detailViewController.segueIdentifier = "DOWNLOAD"
                     let destination = DownloadRequest.suggestedDownloadDestination(
                         for: .cachesDirectory,
                         in: .userDomainMask
                     )
-                    return Alamofire.download("https://httpbin.org/stream/1", to: destination, withMethod: .get)
+                    return Alamofire.download("https://httpbin.org/stream/1", to: destination)
                 default:
                     return nil
                 }

+ 9 - 9
Source/Request.swift

@@ -373,7 +373,7 @@ open class DataRequest: Request {
     ///
     /// - returns: The request.
     @discardableResult
-    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: ProgressHandler) -> Self {
+    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self {
         dataDelegate.progressHandler = (closure, queue)
         return self
     }
@@ -385,7 +385,7 @@ open class DataRequest: Request {
     ///
     /// - returns: The request.
     @discardableResult
-    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: DownloadProgressHandler) -> Self {
+    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping DownloadProgressHandler) -> Self {
         dataDelegate.progressDebugHandler = (closure, queue)
         return self
     }
@@ -420,9 +420,9 @@ open class DownloadRequest: Request {
         }
     }
 
-    /// A closure executed once a download request has successfully completed in order to determine where to move the 
+    /// A closure executed once a download request has successfully completed in order to determine where to move the
     /// temporary file written to during the download process. The closure takes two arguments: the temporary file URL
-    /// and the URL response, and returns a two arguments: the file URL where the temporary file should be moved and 
+    /// and the URL response, and returns a two arguments: the file URL where the temporary file should be moved and
     /// the options defining how the file should be moved.
     public typealias DownloadFileDestination = (
         _ temporaryURL: URL,
@@ -480,7 +480,7 @@ open class DownloadRequest: Request {
     ///
     /// - returns: The request.
     @discardableResult
-    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: ProgressHandler) -> Self {
+    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self {
         downloadDelegate.progressHandler = (closure, queue)
         return self
     }
@@ -492,7 +492,7 @@ open class DownloadRequest: Request {
     ///
     /// - returns: The request.
     @discardableResult
-    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: DownloadProgressHandler) -> Self {
+    open func downloadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping DownloadProgressHandler) -> Self {
         downloadDelegate.progressDebugHandler = (closure, queue)
         return self
     }
@@ -563,7 +563,7 @@ open class UploadRequest: DataRequest {
 
     // MARK: Upload Progress
 
-    /// Sets a closure to be called periodically during the lifecycle of the `UploadRequest` as data is sent to 
+    /// Sets a closure to be called periodically during the lifecycle of the `UploadRequest` as data is sent to
     /// the server.
     ///
     /// After the data is sent to the server, the `progress(queue:closure:)` APIs can be used to monitor the progress
@@ -574,7 +574,7 @@ open class UploadRequest: DataRequest {
     ///
     /// - returns: The request.
     @discardableResult
-    open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: ProgressHandler) -> Self {
+    open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping ProgressHandler) -> Self {
         uploadDelegate.uploadProgressHandler = (closure, queue)
         return self
     }
@@ -590,7 +590,7 @@ open class UploadRequest: DataRequest {
     ///
     /// - returns: The request.
     @discardableResult
-    open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: UploadProgressHandler) -> Self {
+    open func uploadProgress(queue: DispatchQueue = DispatchQueue.main, closure: @escaping UploadProgressHandler) -> Self {
         uploadDelegate.uploadProgressDebugHandler = (closure, queue)
         return self
     }

+ 1 - 1
Source/Response.swift

@@ -194,7 +194,7 @@ extension DownloadResponse: CustomStringConvertible, CustomDebugStringConvertibl
     }
 
     /// The debug textual representation used when written to an output stream, which includes the URL request, the URL
-    /// response, the temporary and destination URLs, the resume data, the response serialization result and the 
+    /// response, the temporary and destination URLs, the resume data, the response serialization result and the
     /// timeline.
     public var debugDescription: String {
         var output: [String] = []

+ 3 - 3
Source/ResponseSerialization.swift

@@ -378,7 +378,7 @@ extension Request {
 }
 
 extension DataRequest {
-    /// Creates a response serializer that returns a result string type initialized from the response data with 
+    /// Creates a response serializer that returns a result string type initialized from the response data with
     /// the specified string encoding.
     ///
     /// - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the server
@@ -465,7 +465,7 @@ extension DownloadRequest {
 // MARK: - JSON
 
 extension Request {
-    /// Returns a JSON object contained in a result type constructed from the response data using `JSONSerialization` 
+    /// Returns a JSON object contained in a result type constructed from the response data using `JSONSerialization`
     /// with the specified reading options.
     ///
     /// - parameter options:  The JSON serialization reading options. Defaults to `.allowFragments`.
@@ -586,7 +586,7 @@ extension DownloadRequest {
 // MARK: - Property List
 
 extension Request {
-    /// Returns a plist object contained in a result type constructed from the response data using 
+    /// Returns a plist object contained in a result type constructed from the response data using
     /// `PropertyListSerialization` with the specified reading options.
     ///
     /// - parameter options:  The property list reading options. Defaults to `[]`.

+ 1 - 1
Source/SessionDelegate.swift

@@ -216,7 +216,7 @@ extension SessionDelegate: URLSessionDelegate {
     open func urlSession(
         _ session: URLSession,
         didReceive challenge: URLAuthenticationChallenge,
-        completionHandler: ((URLSession.AuthChallengeDisposition, URLCredential?) -> Void))
+        completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
     {
         guard sessionDidReceiveChallengeWithCompletion == nil else {
             sessionDidReceiveChallengeWithCompletion?(session, challenge, completionHandler)

+ 1 - 1
Source/SessionManager.swift

@@ -267,7 +267,7 @@ open class SessionManager {
     ///
     /// If `destination` is not specified, the contents will remain in the temporary location determined by the
     /// underlying URL session.
-    /// 
+    ///
     /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned.
     ///
     /// - parameter urlString:   The URL string.

+ 2 - 2
Source/TaskDelegate.swift

@@ -221,7 +221,7 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
         _ session: URLSession,
         dataTask: URLSessionDataTask,
         didReceive response: URLResponse,
-        completionHandler: ((URLSession.ResponseDisposition) -> Void))
+        completionHandler: @escaping (URLSession.ResponseDisposition) -> Void)
     {
         var disposition: URLSession.ResponseDisposition = .allow
 
@@ -284,7 +284,7 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
         _ session: URLSession,
         dataTask: URLSessionDataTask,
         willCacheResponse proposedResponse: CachedURLResponse,
-        completionHandler: ((CachedURLResponse?) -> Void))
+        completionHandler: @escaping (CachedURLResponse?) -> Void)
     {
         var cachedResponse: CachedURLResponse? = proposedResponse
 

+ 4 - 4
Source/Validation.swift

@@ -141,7 +141,7 @@ extension Request {
 
             return AFError.responseValidationFailed(reason: reason)
         }()
-        
+
         return .failure(error)
     }
 }
@@ -161,7 +161,7 @@ extension DataRequest {
     ///
     /// - returns: The request.
     @discardableResult
-    public func validate(_ validation: Validation) -> Self {
+    public func validate(_ validation: @escaping Validation) -> Self {
         let validationExecution: () -> Void = {
             if
                 let response = self.response,
@@ -220,7 +220,7 @@ extension DataRequest {
 // MARK: -
 
 extension DownloadRequest {
-    /// A closure used to validate a request that takes a URL request, a URL response, a temporary URL and a 
+    /// A closure used to validate a request that takes a URL request, a URL response, a temporary URL and a
     /// destination URL, and returns whether the request was valid.
     public typealias Validation = (_ request: URLRequest?, _ response: HTTPURLResponse, _ temporary: URL?, _ destination: URL?) -> ValidationResult
 
@@ -232,7 +232,7 @@ extension DownloadRequest {
     ///
     /// - returns: The request.
     @discardableResult
-    public func validate(_ validation: Validation) -> Self {
+    public func validate(_ validation: @escaping Validation) -> Self {
         let validationExecution: () -> Void = {
             let request = self.request
             let temporaryURL = self.downloadDelegate.temporaryURL

+ 2 - 2
Tests/DownloadTests.swift

@@ -262,7 +262,7 @@ class DownloadResponseTestCase: BaseTestCase {
         XCTAssertNotNil(response?.error)
 
         if let error = response?.error as? CocoaError {
-            XCTAssertEqual(error.code, .fileNoSuchFileError)
+            XCTAssertEqual(error.code, .fileNoSuchFile)
         } else {
             XCTFail("error should not be nil")
         }
@@ -323,7 +323,7 @@ class DownloadResponseTestCase: BaseTestCase {
             XCTAssertNotNil(response?.error)
 
             if let error = response?.error as? CocoaError {
-                XCTAssertEqual(error.code, .fileWriteFileExistsError)
+                XCTAssertEqual(error.code, .fileWriteFileExists)
             } else {
                 XCTFail("error should not be nil")
             }

+ 2 - 2
Tests/ResponseSerializationTests.swift

@@ -898,7 +898,7 @@ class DownloadResponseSerializationTestCase: BaseTestCase {
         XCTAssertTrue(result.isSuccess)
         XCTAssertNotNil(result.value)
         XCTAssertNil(result.error)
-        
+
         if let string = result.value {
             XCTAssertEqual(string, "")
         }
@@ -1196,7 +1196,7 @@ class DownloadResponseSerializationTestCase: BaseTestCase {
         XCTAssertTrue(result.isSuccess)
         XCTAssertNotNil(result.value)
         XCTAssertNil(result.error)
-        
+
         if let plist = result.value as? NSNull {
             XCTAssertEqual(plist, NSNull(), "plist should be equal to NSNull")
         }