Browse Source

Reformatted all MARKs to make it easier to quickly identify different sections.

Christian Noon 10 years ago
parent
commit
2dada34b1e

+ 4 - 4
Source/Alamofire.swift

@@ -83,7 +83,7 @@ extension NSURLRequest: URLRequestConvertible {
     }
 }
 
-// MARK: - Convenience -
+// MARK: - Convenience
 
 func URLRequest(method: Method, URL: URLStringConvertible) -> NSURLRequest {
     let mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: URL.URLString)!)
@@ -92,7 +92,7 @@ func URLRequest(method: Method, URL: URLStringConvertible) -> NSURLRequest {
     return mutableURLRequest
 }
 
-// MARK: - Request
+// MARK: - Request Methods
 
 /**
     Creates a request using the shared manager instance for the specified method, URL string, parameters, and parameter encoding.
@@ -121,7 +121,7 @@ public func request(URLRequest: URLRequestConvertible) -> Request {
     return Manager.sharedInstance.request(URLRequest.URLRequest)
 }
 
-// MARK: - Upload
+// MARK: - Upload Methods
 
 // MARK: File
 
@@ -204,7 +204,7 @@ public func upload(URLRequest: URLRequestConvertible, stream: NSInputStream) ->
     return Manager.sharedInstance.upload(URLRequest, stream: stream)
 }
 
-// MARK: - Download
+// MARK: - Download Methods
 
 // MARK: URL Request
 

+ 5 - 1
Source/Download.swift

@@ -103,6 +103,8 @@ extension Manager {
     }
 }
 
+// MARK: -
+
 extension Request {
     /**
         A closure executed once a 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 single argument: the file URL where the temporary file should be moved.
@@ -128,6 +130,8 @@ extension Request {
         }
     }
     
+    // MARK: - DownloadTaskDelegate
+    
     class DownloadTaskDelegate: TaskDelegate, NSURLSessionDownloadDelegate {
         var downloadTask: NSURLSessionDownloadTask! { return task as! NSURLSessionDownloadTask }
         var downloadProgress: ((Int64, Int64, Int64) -> Void)?
@@ -139,7 +143,7 @@ extension Request {
         var downloadTaskDidWriteData: ((NSURLSession!, NSURLSessionDownloadTask!, Int64, Int64, Int64) -> Void)?
         var downloadTaskDidResumeAtOffset: ((NSURLSession!, NSURLSessionDownloadTask!, Int64, Int64) -> Void)?
         
-        // MARK: NSURLSessionDownloadDelegate
+        // MARK: - NSURLSessionDownloadDelegate
         
         func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
             if downloadTaskDidFinishDownloadingToURL != nil {

+ 28 - 6
Source/Manager.swift

@@ -27,6 +27,8 @@ import Foundation
 */
 public class Manager {
     
+    // MARK: - Properties
+    
     /**
         A shared instance of `Manager`, used by top-level Alamofire request methods, and suitable for use directly for any ad hoc requests.
     */
@@ -96,6 +98,8 @@ public class Manager {
     
     /// The background completion handler closure provided by the UIApplicationDelegate `application:handleEventsForBackgroundURLSession:completionHandler:` method. By setting the background completion handler, the SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` closure implementation will automatically call the handler. If you need to handle your own events before the handler is called, then you need to override the SessionDelegate `sessionDidFinishEventsForBackgroundURLSession` and manually call the handler when finished. `nil` by default.
     public var backgroundCompletionHandler: (() -> Void)?
+
+    // MARK: - Lifecycle
     
     /**
         :param: configuration The configuration used to construct the managed session.
@@ -115,7 +119,7 @@ public class Manager {
         self.session.invalidateAndCancel()
     }
     
-    // MARK: -
+    // MARK: - Request
     
     /**
         Creates a request for the specified method, URL string, parameters, and parameter encoding.
@@ -156,6 +160,8 @@ public class Manager {
         return request
     }
     
+    // MARK: - SessionDelegate
+    
     /**
         Responsible for handling all delegate callbacks for the underlying session.
     */
@@ -180,7 +186,9 @@ public class Manager {
             }
         }
         
-        // MARK: NSURLSessionDelegate
+        // MARK: - NSURLSessionDelegate
+        
+        // MARK: Override Closures
         
         /// NSURLSessionDelegate override closure for `URLSession:didBecomeInvalidWithError:` method.
         public var sessionDidBecomeInvalidWithError: ((NSURLSession, NSError?) -> Void)?
@@ -190,6 +198,8 @@ public class Manager {
         
         /// NSURLSessionDelegate override closure for `URLSessionDidFinishEventsForBackgroundURLSession:` method.
         public var sessionDidFinishEventsForBackgroundURLSession: ((NSURLSession) -> Void)?
+
+        // MARK: Delegate Methods
         
         public func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) {
             sessionDidBecomeInvalidWithError?(session, error)
@@ -207,7 +217,9 @@ public class Manager {
             sessionDidFinishEventsForBackgroundURLSession?(session)
         }
         
-        // MARK: NSURLSessionTaskDelegate
+        // MARK: - NSURLSessionTaskDelegate
+        
+        // MARK: Override Closures
         
         /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:`.
         public var taskWillPerformHTTPRedirection: ((NSURLSession, NSURLSessionTask, NSHTTPURLResponse, NSURLRequest) -> (NSURLRequest!))?
@@ -224,6 +236,8 @@ public class Manager {
         /// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didCompleteWithError:`.
         public var taskDidComplete: ((NSURLSession, NSURLSessionTask, NSError?) -> Void)?
         
+        // MARK: Delegate Methods
+        
         public func URLSession(session: NSURLSession, task: NSURLSessionTask, willPerformHTTPRedirection response: NSHTTPURLResponse, newRequest request: NSURLRequest, completionHandler: ((NSURLRequest!) -> Void)) {
             var redirectRequest: NSURLRequest? = request
             
@@ -270,7 +284,9 @@ public class Manager {
             }
         }
         
-        // MARK: NSURLSessionDataDelegate
+        // MARK: - NSURLSessionDataDelegate
+        
+        // MARK: Override Closures
         
         /// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
         public var dataTaskDidReceiveResponse: ((NSURLSession, NSURLSessionDataTask, NSURLResponse) -> (NSURLSessionResponseDisposition))?
@@ -283,6 +299,8 @@ public class Manager {
         
         /// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:willCacheResponse:completionHandler:`.
         public var dataTaskWillCacheResponse: ((NSURLSession, NSURLSessionDataTask, NSCachedURLResponse) -> (NSCachedURLResponse!))?
+
+        // MARK: Delegate Methods
         
         public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: ((NSURLSessionResponseDisposition) -> Void)) {
             var disposition: NSURLSessionResponseDisposition = .Allow
@@ -321,7 +339,9 @@ public class Manager {
             }
         }
         
-        // MARK: NSURLSessionDownloadDelegate
+        // MARK: - NSURLSessionDownloadDelegate
+        
+        // MARK: Override Closures
         
         /// Overrides default behavior for NSURLSessionDownloadDelegate method `URLSession:downloadTask:didFinishDownloadingToURL:`.
         public var downloadTaskDidFinishDownloadingToURL: ((NSURLSession, NSURLSessionDownloadTask, NSURL) -> Void)?
@@ -331,6 +351,8 @@ public class Manager {
         
         /// Overrides default behavior for NSURLSessionDownloadDelegate method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`.
         public var downloadTaskDidResumeAtOffset: ((NSURLSession, NSURLSessionDownloadTask, Int64, Int64) -> Void)?
+
+        // MARK: Delegate Methods
         
         public func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {
             if downloadTaskDidFinishDownloadingToURL != nil {
@@ -356,7 +378,7 @@ public class Manager {
             }
         }
         
-        // MARK: NSObject
+        // MARK: - NSObject
         
         public override func respondsToSelector(selector: Selector) -> Bool {
             switch selector {

+ 2 - 0
Source/ParameterEncoding.swift

@@ -39,6 +39,8 @@ public enum Method: String {
     case CONNECT = "CONNECT"
 }
 
+// MARK: - ParameterEncoding
+
 /**
     Used to specify the way in which a set of parameters are applied to a URL request.
 */

+ 11 - 5
Source/Request.swift

@@ -58,7 +58,7 @@ public class Request {
         }
     }
     
-    // MARK: Authentication
+    // MARK: - Authentication
     
     /**
         Associates an HTTP Basic credential with the request.
@@ -87,7 +87,7 @@ public class Request {
         return self
     }
     
-    // MARK: Progress
+    // MARK: - Progress
     
     /**
         Sets a closure to be called periodically during the lifecycle of the request as data is written to or read from the server.
@@ -111,7 +111,7 @@ public class Request {
         return self
     }
     
-    // MARK: Response
+    // MARK: - Response
     
     /**
         A closure used by response handlers that takes a request, response, and data and returns a serialized object and any error that occured in the process.
@@ -161,6 +161,8 @@ public class Request {
         return self
     }
     
+    // MARK: - State
+    
     /**
         Suspends the request.
     */
@@ -188,6 +190,8 @@ public class Request {
         }
     }
     
+    // MARK: - TaskDelegate
+    
     class TaskDelegate: NSObject, NSURLSessionTaskDelegate {
         let task: NSURLSessionTask
         let queue: NSOperationQueue
@@ -221,7 +225,7 @@ public class Request {
             queue.suspended = true
         }
         
-        // MARK: NSURLSessionTaskDelegate
+        // MARK: - NSURLSessionTaskDelegate
         
         func URLSession(session: NSURLSession, task: NSURLSessionTask, willPerformHTTPRedirection response: NSHTTPURLResponse, newRequest request: NSURLRequest, completionHandler: ((NSURLRequest!) -> Void)) {
             var redirectRequest = request
@@ -270,6 +274,8 @@ public class Request {
         }
     }
     
+    // MARK: - DataTaskDelegate
+    
     class DataTaskDelegate: TaskDelegate, NSURLSessionDataDelegate {
         var dataTask: NSURLSessionDataTask! { return task as! NSURLSessionDataTask }
         
@@ -291,7 +297,7 @@ public class Request {
             super.init(task: task)
         }
         
-        // MARK: NSURLSessionDataDelegate
+        // MARK: - NSURLSessionDataDelegate
         
         func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: ((NSURLSessionResponseDisposition) -> Void)) {
             var disposition: NSURLSessionResponseDisposition = .Allow

+ 2 - 2
Source/ResponseSerialization.swift

@@ -65,7 +65,7 @@ extension Request {
     }
 }
 
-// MARK: JSON
+// MARK: - JSON
 
 extension Request {
     /**
@@ -103,7 +103,7 @@ extension Request {
     }
 }
 
-// MARK: Property List
+// MARK: - Property List
 
 extension Request {
     /**

+ 6 - 1
Source/Upload.swift

@@ -158,12 +158,17 @@ extension Manager {
     }
 }
 
+// MARK: -
+
 extension Request {
+    
+    // MARK: - UploadTaskDelegate
+    
     class UploadTaskDelegate: DataTaskDelegate {
         var uploadTask: NSURLSessionUploadTask! { return task as! NSURLSessionUploadTask }
         var uploadProgress: ((Int64, Int64, Int64) -> Void)!
         
-        // MARK: NSURLSessionTaskDelegate
+        // MARK: - NSURLSessionTaskDelegate
         
         func URLSession(session: NSURLSession!, task: NSURLSessionTask!, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) {
             progress.totalUnitCount = totalBytesExpectedToSend

+ 3 - 3
Source/Validation.swift

@@ -50,7 +50,7 @@ extension Request {
         return self
     }
     
-    // MARK: Status Code
+    // MARK: - Status Code
     
     /**
         Validates that the response has a status code in the specified range.
@@ -67,7 +67,7 @@ extension Request {
         }
     }
     
-    // MARK: Content-Type
+    // MARK: - Content-Type
     
     private struct MIMEType {
         let type: String
@@ -123,7 +123,7 @@ extension Request {
         }
     }
     
-    // MARK: Automatic
+    // MARK: - Automatic
     
     /**
         Validates that the response has a status code in the default acceptable range of 200...299, and that the content type matches any specified in the Accept HTTP header field.