Skip to content

Commit

Permalink
Removed var function parameter in ResponseSerialization to build unde…
Browse files Browse the repository at this point in the history
…r newest Swift toolchain.
  • Loading branch information
vivid-cieslak authored and cnoon committed Feb 8, 2016
1 parent e748b44 commit 59ef4f5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/ResponseSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ extension Request {
- returns: A string response serializer.
*/
public static func stringResponseSerializer(
var encoding encoding: NSStringEncoding? = nil)
encoding encoding: NSStringEncoding? = nil)
-> ResponseSerializer<String, NSError>
{
return ResponseSerializer { _, response, data, error in
Expand All @@ -208,14 +208,16 @@ extension Request {
let error = Error.errorWithCode(.StringSerializationFailed, failureReason: failureReason)
return .Failure(error)
}

if let encodingName = response?.textEncodingName where encoding == nil {
encoding = CFStringConvertEncodingToNSStringEncoding(

var convertedEncoding = encoding

if let encodingName = response?.textEncodingName where convertedEncoding == nil {
convertedEncoding = CFStringConvertEncodingToNSStringEncoding(
CFStringConvertIANACharSetNameToEncoding(encodingName)
)
}

let actualEncoding = encoding ?? NSISOLatin1StringEncoding
let actualEncoding = convertedEncoding ?? NSISOLatin1StringEncoding

if let string = String(data: validData, encoding: actualEncoding) {
return .Success(string)
Expand Down

0 comments on commit 59ef4f5

Please sign in to comment.