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

Asserts when receiving an NSArray instead of an NSDictionary #31

Closed
alexito4 opened this issue May 7, 2014 · 3 comments
Closed

Asserts when receiving an NSArray instead of an NSDictionary #31

alexito4 opened this issue May 7, 2014 · 3 comments

Comments

@alexito4
Copy link

alexito4 commented May 7, 2014

Hi, I just updated to 2.5 and I'm really excited with the new features :)

Before the update I was using a modified version in which I surrounded some methods with a try/catch to avoid crashes in the testers devices because of the API changing constantly. Now I was thinking of use the new version to accomplish the same purpose, but I encountered a problem with an assertion.

JSON I expect:

{
    ...
    thing: 
        {
            a1 : "hello",
            ...
        },
    ...
}

Mapping:

    [KZPropertyMapper mapValuesFrom:properties 
                          toInstance:self
                       usingMapping:@{
                                  @"a1" : KZProperty(attribute1),
                                  }
     ];

JSON I'm reciving:

{
    ...
    thing: [],
    ...
}

This Asserts on line 252: AssertTrueOrReturn([key isKindOfClass:NSNumber.class]); inside the enumeration block.

The problem is natural. I'm giving an array to the mapper when it expects a dictionary. The crash is absolutely normal but with the new feature I was hoping that this won't happen anymore.
If this is the desired behaviour there is no problem ;)

@marekcirkos
Copy link

Hi, thanks for checking out new version :).
Can you try to compile in KZPM as Release? It should not fire assert and should not crash.
I thought it might be useful to know when JSON is different then expected while you developing.

@krzysztofzablocki
Copy link
Owner

I agree with @marek, asserts are for catching problems in debug builds, if you strip asserts (as release does by default) this will not crash, it will just ignore that mapping.

@alexito4
Copy link
Author

alexito4 commented May 7, 2014

Thanks guys!
I had a misconfiguration in the test build. Sorry for that. Now works as expected.
I really like how is working right now, this rocks! ;)

@alexito4 alexito4 closed this as completed May 7, 2014
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