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

How to use ValueTransformer in swift3? can you give me a sample pplease #80

Open
bizibizi opened this issue Aug 1, 2017 · 5 comments
Open
Labels

Comments

@bizibizi
Copy link

bizibizi commented Aug 1, 2017

No description provided.

@gonzalezreal
Copy link
Owner

You can find an example of ValueTransformer in the unit tests:
https://github.com/gonzalezreal/Groot/blob/master/GrootTests/SerializationTests.swift#L23

And remember that the value transformer for a property is configured in the .xcdatamodel file:
https://github.com/gonzalezreal/Groot/blob/master/GrootTests/Model.xcdatamodeld/Model.xcdatamodel/contents#L39

@bizibizi
Copy link
Author

bizibizi commented Aug 2, 2017

and where should I place the code? I have class Animal, (Animal and _Animal). So, in Animal clasbut in what method? or after/before parsing data?

@gonzalezreal
Copy link
Owner

The value transformer(s) should be setup once before parsing. Usually application startup is a good place.

@bizibizi
Copy link
Author

bizibizi commented Aug 3, 2017

ok, and type in Model should be Transformable, right?
but in that case I will need to convert property to needed type?

@gonzalezreal
Copy link
Owner

The type in the model doesn't need to be transformable. Please have a look at this document to get to know how Groot annotations work.

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

No branches or pull requests

2 participants