Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping NSDecimalNumber #145

Closed
danyalaytekin opened this issue Jul 2, 2015 · 4 comments
Closed

Mapping NSDecimalNumber #145

danyalaytekin opened this issue Jul 2, 2015 · 4 comments

Comments

@danyalaytekin
Copy link

My approach fails. n is set to nil, whereas it is set correctly if its type is Double?. Is there a correct way to do this?

class Model: Mappable
{
    var n: NSDecimalNumber?

    required init?(_ map: Map)
    {
        super.init()
        mapping(map)
    }

    func mapping(map: Map)
    {
        n <- map["n"]
    }    
}
@tristanhimmelman
Copy link
Owner

ObjectMapper doesn't support NSDecimalNumber. We are avoiding Objective-C types when possible.

If you need a NSDecimalNumber, you can consider using a CustomTransform to support it.

@jonasman
Copy link

NSDecimalNumber must be taken in consideration. There is no replacement for this type in Swift. This is the only type that can be used to represent money. Double or float is not an alternative.

@rebe1one
Copy link

@jonasman While I agree with you, there is an included NSDecimalNumberTransform in ObjectMapper, so this is a minor inconvenience.

@jonasman
Copy link

That sounds good then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants