Skip to content

Commit

Permalink
Simplified error checking while unboxing string array
Browse files Browse the repository at this point in the history
  • Loading branch information
clayellis committed Jul 26, 2016
1 parent 5a4f0b9 commit 7edfe75
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Sources/Unbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,12 @@ public class Unboxer {
}

let transformedStringArray = UnboxValueResolver<[String]>(self).resolveOptionalValueForKey(key, isKeyPath: isKeyPath, transform: { stringArray -> [T]? in
do {
return try stringArray.flatMap {
guard let transformedUnboxedString = T.transformUnboxedString($0) else { throw UnboxValueError.InvalidValue($0, key) }
return transformedUnboxedString
}
} catch {
return nil
var transformedStringArray = [T]()
for string in stringArray {
guard let transformedUnboxedString = T.transformUnboxedString(string) else { return nil }
transformedStringArray.append(transformedUnboxedString)
}
return transformedStringArray
})

if let transformedStringArray = transformedStringArray {
Expand Down

0 comments on commit 7edfe75

Please sign in to comment.