Question

My question is pretty clear, I think, but to provide context I'm re-building an application that was used for judging in a contest. One of the issues we're trying to address is data corruption; one of the devices had it's data store completely corrupted by receiving bad data from the server (which it promptly uploaded back to the server, corrupting the server as well). For obvious reasons, this is a bug that needs fixing -- both from a practical 'can we use this app again' standpoint and from a point of programmer's pride and reputation.

There are two scenarios for how this might have happened. The first scenario is character encoding failures, which I think I can safely ignore because JSON was used to transfer the data around -- and JSON mandates the use of a specific character encoding (UTF-8). I'm planning to use RESTKit for version 2.0 of the app, so (hopefully) restkit

The second scenario is the one I'm wrestling with, because the Wi-Fi at the event was horrible. While it seems unlikely, evidence suggests that it's at least possible for the actual TCP communications stream to be compromised without causing the resulting data to fail JSON validation.

All of which leads me to ask what tools (or underlying, automatically activated features) does iOS and/or RestKit provide to help protect against the data being corrupted in transit? (Since I control the server code, I can change what the API reports if needed)

Was it helpful?

Solution

Over the top of the parse of the data being valid (the content confirms to the standard) there is nothing. TCP offers some protection.

Depending on where you're trying to protect you could consider adding a hash to the response so you can verify that the received content matches the sent content.

From an SDK standpoint you have KVC validation (which RestKit ties into heavily). This allows you to check each field of each object during the mapping process and bin any objects that fail the validation checks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top