Skip to content

Commit

Permalink
Add support for arrays of transformables.
Browse files Browse the repository at this point in the history
Fixes #85.
  • Loading branch information
Maximilian Szengel committed Jul 20, 2016
1 parent b92074c commit ea04648
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/Unbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ public class Unboxer {
public func unbox<T: CollectionType>(key: String, isKeyPath: Bool = true) -> [T]? {
return UnboxValueResolver<[T]>(self).resolveOptionalValueForKey(key, isKeyPath: isKeyPath)
}

/// Unbox a required Array of values that can be transformed into its final form
public func unbox<T: UnboxableByTransform>(key: String, isKeyPath: Bool = true) -> [T] {
return UnboxValueResolver<[T]>(self).resolveRequiredValueForKey(key, isKeyPath: isKeyPath, fallbackValue: [])
}

/// Unbox an optional Array of values that can be transformed into its final form
public func unbox<T: UnboxableByTransform>(key: String, isKeyPath: Bool = true) -> [T]? {
return UnboxValueResolver<[T]>(self).resolveOptionalValueForKey(key, isKeyPath: isKeyPath)
}

/// Unbox a required raw value from a certain index in a nested Array
public func unbox<T: UnboxableRawType>(key: String, isKeyPath: Bool = true, index: Int) -> T {
Expand Down

0 comments on commit ea04648

Please sign in to comment.