How does one store data on a server from an iOS app?
If I create, e.g. a JSON object, how can I send this to the server and save it on the server as the value from some Key?
I am using MAMP at the moment and have seen examples of how to create the item on the server and get it to the phone, I would like to learn how to create objects on the device, send them to the server for storage. such as a JSON object and store it on the server as a value for e.g. a key with an ID.
I would greatly appreciate any help with this.
Have a look at NSUrlConnection
. Using it you can synchronously & asynchronously transmit data to your server using a POST request.
Check out ASIHTTPRequest. It can GET/POST from a URL asynchronously and for storage, if the data set is small enough look at NSUserDefaults.
On the server side (if the scripts are PHP), you can handle the data in the $_POST and $_GET variables just as if they were populated from the web.
If you wanted you could post the variables individually in their own $_POST or $_GET variables, or as 1 JSON string which you could decode when you receive it.
You may also want to check out RestKit which will make things easier when dealing with downloading/uploading/processing JSON.