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

Nice to have: DCDictionaryMapping #60

Open
albsala opened this issue Sep 7, 2014 · 2 comments
Open

Nice to have: DCDictionaryMapping #60

albsala opened this issue Sep 7, 2014 · 2 comments

Comments

@albsala
Copy link

albsala commented Sep 7, 2014

It would be nice to have a class like "DCArrayMapping" for NSDictionary, because I have a JSON like this:

{
    "_id":12345,
    "localizedContent":{
        "en":{
            "name":"english name"
        },
        "es":{
            "name":"spanish name"
        }
    }
}

... with an undetermined number of languages, so I'm trying to map it to an object like this:

@interface MyLocalizedContent : NSObject

@property (nonatomic, strong) NSString *name;

@end


@interface MyObject : NSObject

@property (nonatomic, strong) NSNumber *identifier;
@property (nonatomic, strong) NSDictionary *localizedContent;

@end

... and I don't know how to do it without this "DCDictionaryMapping".

@albsala
Copy link
Author

albsala commented Sep 8, 2014

After hours of tests :) I have solved it using DCCustomParserBlock but it would nice to have a DCDictionaryMapping anyway.

BTW: I have lost so much time figuring out why this didn't work:

DCCustomParser *customParser = [[DCCustomParser alloc] initWithBlockParser:parserBlock
                                                          forAttributeName:@"localizedContent"
                                                        onDestinationClass:[MyObject class]];

until i tried this:

DCCustomParser *customParser = [[DCCustomParser alloc] initWithBlockParser:parserBlock
                                                          forAttributeName:@"_localizedContent"
                                                        onDestinationClass:[MyObject class]];

@d370urn3ur
Copy link

Wow thanks man I lost probably 3 hours trying to figure out why DCCustomParser didn't work. we need docs on DCCustomParser!

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

2 participants