2
0
Эх сурвалжийг харах

Added initializer to GenericResponseSerializer to fix initialization bug.

Christian Noon 10 жил өмнө
parent
commit
1978c2c926

+ 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