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

Is not key value coding-compliant for the key __response_statusCode? #37

Closed
Dbigshooter opened this issue Nov 15, 2016 · 10 comments
Closed
Labels

Comments

@Dbigshooter
Copy link

Dbigshooter commented Nov 15, 2016

Just updated EVReflection and this lib, and all my classes says this, what is that?


WARNING: The class 'ClassName' is not key value coding-compliant for the key '__response_statusCode'
 There is no support for optional type, array of optionals or enum properties.
As a workaround you can implement the function 'setValue forUndefinedKey' for this. See the unit tests for more information
@evermeer
Copy link
Owner

The key __response_statusCode will be added when the http status code is 200 or higher.
AlamofireJsonToObjects will still try to parse the object because some systems will also return an error object in json format.

You can choose to include the error fields inside your object (or in a base class) or you could use the getSpecificType function to get an error object.

The question is why you are getting a status code >= 200

@Dbigshooter
Copy link
Author

Dbigshooter commented Nov 15, 2016

But it shouldn't be a problem to get a 200 status code? I see no errors with me calls what so ever?

@evermeer
Copy link
Owner

You are right. It should be > 200. I have changed the code that if its 200 you won't get __response_statusCode

@Dbigshooter
Copy link
Author

Dbigshooter commented Nov 16, 2016

I still see the same outcome? I get status code 200 on all my requests. Have you pushed it to cocoapods?

@evermeer
Copy link
Owner

2.3.1 is the latest release both in Cocoapods as in GitHub.

As a test I just downloaded the latest release from https://github.com/evermeer/AlamofireJsonToObjects/releases

When I look at AlamofireJsonToObjects.swif I see this check twice:
if response?.statusCode ?? 0 > 200 {

So If you do have that update, it should only get the __response_statusCode if the statusCode is above 200

So do you have the same code? If not, then why is it not updated to the latest version? If you do have the code, then your status code should be above 200. Or am I missing something else?

@Dbigshooter
Copy link
Author

Dbigshooter commented Nov 16, 2016

I imagine you should do the check on >= 300, since status codes in the 200 range is just fine. 201 = created, 202 = accepted and so on.

When I updated my repo I just got version 2.2.0 from cocoapods? Does the new version require the beta of new release of cocoapods?

@evermeer
Copy link
Owner

I don't know why you would get the old version... Could it be because of the supported OS version? Since Swift 3 it should be iOS 8 and up. I will change the status check to >= 300

@Dbigshooter
Copy link
Author

Wow, my bad. I had the library in the pod set to a specific branch, my apologies.

@evermeer
Copy link
Owner

no worries 😎

@evermeer
Copy link
Owner

I just pushed a new version (2.4.0) with better support for handling HTTP error statuses.

It's explained in the readme. For a unit test demonstrating this, see:
https://github.com/evermeer/AlamofireJsonToObjects/blob/master/AlamofireJsonToObjectsTests/AlamofireJsonToObjectsTests.swift#L81

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