-
Notifications
You must be signed in to change notification settings - Fork 45
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
Feature Request: Can OCMapper figure out the property/var type automatically? #49
Comments
Hey @jpage4500 Does it not work? mapping for properties should work automatically as long as they key in dictionary matches the property name. https://github.com/aryaxt/OCMapper/blob/master/OCMapperTests/ObjectMapperTests.m#L75 The only exception would be for arrays For mapping arrays, ObjectMapper finds an appropriate class based on property name (singular, plural name) instead of using reflection (runtime API doesn't give you the type of objects in the array) |
Hi @aryaxt - it doesn't seem to work all of the time for me. For example, after receiving your update I commented out a few mappings to test. The first one worked but others failed to parse - giving lots of errors in the log. I did notice 1 thing that's different in my code than what I originally stated.. the server returns "home_team" and my property is called "homeTeam". I know OCMapper automatically handles this since it's working in lots of other places for me. But, could there be an issue when OCMapper needs to do both:
Here's what I have below (which works) - but if I comment out the mapping it fails.
Sorry, I should have also mentioned I have a simple mapper() function to get the singleton:
|
Right now we're using mapFromDictionaryKey() to map a variable to the class type which works fairly well. But, as I remember in Android GSON will automatically detect the type and just parse it using that class.
Just curious - is there a way OCMapper can figure this out itself?
ie: any way OCMapper could figure out that homeTeam variable is of class type GameStatusTeam and not require the mapping below?
The text was updated successfully, but these errors were encountered: