Bläddra i källkod

Added initializer to GenericResponseSerializer to fix initialization bug.

Christian Noon 10 år sedan
förälder
incheckning
1978c2c926
1 ändrade filer med 11 tillägg och 0 borttagningar
  1. 11 0
      Source/ResponseSerialization.swift

+ 11 - 0
Source/ResponseSerialization.swift

@@ -44,6 +44,17 @@ public struct GenericResponseSerializer<T>: ResponseSerializer {
 
     /// 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.
     public var serializeResponse: (NSURLRequest?, NSHTTPURLResponse?, NSData?) -> (SerializedObject?, NSError?)
+
+    /**
+        Initializes the `GenericResponseSerializer` instance with the given serialize response closure.
+
+        :param: serializeResponse The closure used to serialize the response.
+
+        :returns: The new generic response serializer instance.
+    */
+    public init(serializeResponse: (NSURLRequest?, NSHTTPURLResponse?, NSData?) -> (SerializedObject?, NSError?)) {
+        self.serializeResponse = serializeResponse
+    }
 }
 
 // MARK: - Default