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
How to use InCodeMappingProvider with swift #16
Comments
mappingProvider.mapFromDictionaryKey("description", toPropertyKey:"fullDescription", forClass:User..self) |
Yes but what about the value for the parameter withTransformer? I'm using a closure but it does not works. Thanks for the help. |
Oops overlooked it. Don't have swift setup so gonna take a guess. mappingProvider.mapFromDictionaryKey("description", toPropertyKey:"fullDescription", forClass:User.self) { node, parent in
// node & parent are AnyObject to you need to cast them to appropriate type to use them (use if let)
return "Something"
} |
Humm... this works but when using directly the parameter withTransformer in 3rd example below, I'm not able to make it work. Weird. The first 2 examples work, but not the third one. The one I was using of course:
|
I always got the error: Argument withTransformer must precede argument forClass. If you found whats causing the issue, please let me know. Thanks a lot for your help and librairie! It help the community a lot. |
So do the first 2 examples still not work? |
First 2 are working, and yes I saw that in missing for the third one. Still not working. |
That's odd. Maybe change AnyObject to Any? |
I tried yes, nope. |
Oh god! Of course...
Again, swift error was a big help, haha! Thanks again for your help. |
cool, good catch. Hopefully Xcode 6.3 is gonna be more informative about errors :) |
Hi! Just found this Github projects, it looks amazing! And I am thinking about replacing JSONJoy with it, since JSONJoy does not automatically match JSON values to Model properties. Where can I put the inCodeMappingProvider.mapFromDictionaryKey code, when I want to use another name of my property than the JSON key? I am using Swift, Alamofire and the Alamofire.Request extension Can I add code for "re-mapping" of property-JSONkey names inside the init for each model? Extremely thankful for any help! Thanks! :) |
@Sajjon Glad you found it helpful. I personally don't like adding parsing logic to models, I usually create a mapping manager file that has all my mapping, and I call it from appDelegate. Take a look at this class: https://github.com/aryaxt/OCMapper/blob/master/OCMapper/Sample/Service%20Layer/OCMapperConfig.m |
Hi,
I'm not sure this question is relevant but how do you use:
in swift?
I always got the following error: Argument withTransformer must precede argument forClass.
Could you post an example of this method used in Swift please.
Thanks.
The text was updated successfully, but these errors were encountered: