Skip to content

Commit

Permalink
Add ImmutableMutable initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Sep 23, 2016
1 parent 160e2a8 commit 0e4a4d5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ObjectMapper/Core/ImmutableMappble.swift
Expand Up @@ -152,6 +152,21 @@ public extension Map {

}

public extension ImmutableMappable {

/// Initializes object from a JSON String
public init(JSONString: String, context: MapContext? = nil) throws {
self = try Mapper(context: context).map(JSONString: JSONString)
}

/// Initializes object from a JSON Dictionary
public init?(JSON: [String: Any], context: MapContext? = nil) throws {
self = try Mapper(context: context).map(JSON: JSON)
}

}


public extension Mapper where N: ImmutableMappable {

public func map(JSON: [String: Any]) throws -> N {
Expand Down

0 comments on commit 0e4a4d5

Please sign in to comment.