Skip to content

Commit 330cbe6

Browse files
author
Baris Sencan
committed
Primitive type deserialization code improvements.
1 parent 91d1960 commit 330cbe6

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

JSONHelper/Pod Classes/JSONHelper.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,20 @@ infix operator <<< { associativity right precedence 150 }
8888

8989
// For optionals.
9090
public func <<<<T>(inout property: T?, value: AnyObject?) -> T? {
91+
var newValue: T?
9192

9293
if let unwrappedValue: AnyObject = value {
9394

9495
if let convertedValue = unwrappedValue as? T {
95-
property = convertedValue
96+
newValue = convertedValue
9697
} else if property is Int? && unwrappedValue is String {
9798

9899
if let intValue = "\(unwrappedValue)".toInt() {
99-
property = intValue as T
100-
} else {
101-
property = nil
100+
newValue = intValue as T
102101
}
103-
} else {
104-
property = nil
105102
}
106-
} else {
107-
property = nil
108103
}
109-
104+
property = newValue
110105
return property
111106
}
112107

0 commit comments

Comments
 (0)