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

Property name mapping doesn't support underscore at the middle of the property name? #47

Closed
seaguest opened this issue Apr 2, 2016 · 3 comments

Comments

@seaguest
Copy link

seaguest commented Apr 2, 2016

Hello,

I just found a problem of property name mapping when we have underscore at the middle of the property.

This is linked to
#46

My Model is:

@interface User : NSObject
@property (nonatomic) int user_id;
@property (nonatomic) NSString* registration;
@end

The dictionary is:

{
    registration = "my test registration";
    "user_id" = 10;
}

However OCMapper mapped user_id to userid(without underscore), I guess this is not supposed to be, you may want to map userid to _userid but forgetting the case when we have underscore at the middle.

Ok, I see the code in

    @implementation ObjectInstanceProvider

    // Support underscore case (EX: map first_name to firstName)
    caseInsensitivePropertyName = [caseInsensitivePropertyName stringByReplacingOccurrencesOfString:@"_" withString:@""];

I just saw that automatic underscore mapping from the latest changelog, but what if we want to keep the same name as in he dictionary?

@seaguest
Copy link
Author

seaguest commented Apr 4, 2016

as a workaround, I just removed that line of code,
but it would be better if it can allow user to choose wither default same name mapping or differen name mapping.

@aryaxt
Copy link
Owner

aryaxt commented May 8, 2016

Hi, yes sorry this is not supported, objective c property naming convention is camel case

@aryaxt aryaxt closed this as completed May 8, 2016
@lorenzoPrimi
Copy link

That was really annoying, spent two hours debugging it to discover that the component remove the underscores in the var names.
As I want to use the Pod, can that replace be optional instead of compulsory?

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

3 participants