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

Crash on JSON decode #14

Closed
tuoxie007 opened this issue Apr 9, 2013 · 1 comment
Closed

Crash on JSON decode #14

tuoxie007 opened this issue Apr 9, 2013 · 1 comment

Comments

@tuoxie007
Copy link

NSJSONSerialization by Apple cannot process nil data, the responseData returned from NSURLConnection can be nil, so that would be a crash. That happened on the two lines.

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

id parsedJSONResponse = removeNull([NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil]);

So, could you check nil before decoding ? Thanks

@natesymer
Copy link
Owner

Yeah sure, I'll do it tomorrow.

Sent from my iPhone

On Apr 9, 2013, at 11:36 AM, Jason Hsu notifications@github.com wrote:

NSJSONSerialization by Apple cannot process nil data, the responseData returned from NSURLConnection can be nil, so that would be a crash. That happened on the two lines.

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

id parsedJSONResponse = removeNull([NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil]);
So, could you check nil before decode it ? Thank you !


Reply to this email directly or view it on GitHub.

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