iOS saving core data to server/cloud - iphone

I'm using core data in our iOS universal application and want the ability for the user to back their data up to our server. So they can log in with another device and pull down that data to that device. Has anyone got any advice on this? I want to analyse the data at the server to synchronise information with our stores as well, so the data must be readable via the server end as well.
I want to send the entire core data store over in one push, so will be an XML mashup of entities from the core data store that will be deciphered on retrieval.
How can I do this?

Have accomplished this using GDataxml to build the xml string and push it through a web service at the server end. Performance is great.

Your duplicating some iCloud functionality here. Why not leave the cloud storage and retrieval to iCloud and then when the app starts, synchronise with your server

Related

Syncing Database (sqlite) from WebService(Json/XML) for iOS

I have a Web Service and sqlite database. In this, web service will be used to store data inside database. Now I want to include sync functionality as - Whenever application starts at that time the database will start to load its table's data through web service.
Now after some time when I update my my web service the database will be updated accordingly. My question is that what are the best practices that I must follow for this update. Should I clear whole DB and start adding all rows again(I know this will take a lot time) but If not this then how do my database will add only particular data from the web service?
Thank you.
What I suggest you is:
store all your webservice content into db first when the app starts.
display your content on the screen from db only.
again when you need to refresh or recall your data just update the database.
Thus, you will always find all your fresh data into database.
Downloading and updating the entire server data will prove expensive. It will use more bandwidth and prove costly to your customer. Rather than pushing the entire load (even for minor update), send a delta. I will suggest you to maintain version information.
When application downloads the data from web service for a said version and store it successfully in the database, set the current updated version as well in the DB.
When app starts the next time, make a light weight header request to get just the version info from the server. The server should respond to this header request with the latest data version number.
Check the version from WS with the current application data version stored in the DB. If the server has an updated version, start the sync.
The version change information should be delta i.e.
For new version, server should send only the information that is changed since the version available with the device.
You server should have capability to calculate the delta between two versions.
Delta information will typically have sections like, new data, updated data, deleted data etc.
Based on this, the iOS app will make the necessary CRUD(Create, Read, Update and Delete) operations on the DB data.
Once the iOS app updates itself, then you can update the DB version to the latest received version from server. Until then let it remain dirty for proper error handling.
Hope that helps.
I would recommend you use RestKit's superb Core Data support.
By using RKEntityMapping you can map your remote objects from JSON or XML directly to Core Data entities in your database.
RestKit will automatically maintain the database for you, inserting and updating entries as appropriate from your web service. (In my experience, I've found deleting objects requires a tiny bit of extra work depending on how RESTful your web service is).
RestKit definitely does have a learning curve attached, but it's well worth it: having deployed it a couple of times now, is definitely a much better solution than manually writing your own SQLite/Web Service syncing code.
First you need to set all webservice content into your SQLITE.and what you want to display get that data from SQLITE.and perform opertaion into that sqlite table and when once all this done you need to changes made are saved it into webservice.
Follow this way.

Easiest technic for syncing files

I am developing an iphone application and I don't know which would be the best approach to sync data between the application and a server.
I'd like to work with data in my application even if there is no internet connection, and sync the data when the device reconnects.
First I thought of using a local database, but I have no idea how to sync the records. At least, I can't imagine an easy way to do it.
How could I sync a local database to a remote one?
Should I think in using files (like json or xml) to store my data instead?
How would I sync files?
Thanks.

iphone data storage to remote SQL database server

I have a task at hand to create a iphone app which is required to do the following.
the app should get the data entered by the user and store it into a remote server database.
other app user can see the data in the remote database.
store login information of the user using the app so as to keep track of what information as uploaded and by who
the thing that i would like to know.
1) What SQL server database is best to accomplish the task.
2) what format is best to retrieve the information from the database.
3) how to send the data from the iphone to the remover server database to it can store the data.
i read up on SQLite and found out that this particular database is a offline which stores the data locally so it cannot be viewed by other used. i wan to use a SQL database which can be accessed remotely.
1) What SQL server database is best to accomplish the task.
For implementation on server side, you can implement any server database, it does not matter. For implementation on iphone device, you have to implement SQLite database, which will provide storage locally.
2) what format is best to retrieve the information from the database.
You can retrieve data using XML or JSON format which will be parsed in device and can be stored in SQLite database, it is the easiest way to transfer data between client and server.
3) how to send the data from the iphone to the remover server database to it can store the data.
You can send data from iphone to server in XML/JSON format or by passing parameters in POST or GET request method then this format is parsed on server side and store data on server database.
For all this, you will require to implement API on server side, which will be the interface between server and device.
I know you mention SQL specifically, but is this a requirement or just a choice based on what most other people are doing? I ask because personally I would give serious thought to using a NoSQL database (document store) like couchdb for such a task. Deploying couch means you often don't need server side application layer at all, the way you will for a SQL based solution.
You talk to couch using HTTP which is perfectly suited to the ASIHTTPRequest library for example. Fetching data is usually a GET request and storing documents is done with PUT. All the data in or out comes back as JSON so a good JSON library will make life easier.
The combination of couchdb and the 2 libraries linked above, makes developing a data driven application really, really easy.
That's how I would do it ...
If you really need to stick with SQL, then as Jignesh says, use whatever database you like and implement a suitable API in the server side language of your choice. You can transfer the data however you like although JSON would still get my vote as a relatively light protocol that remains human readable.
You can use a cloud-enabled database service, like windows azure.

Design patterns when working with JSON web service and Core Data?

I have a iPhone app which loads json from my webservice.
I think its a good idea to store the data with Core Data but how should I sync the data with my webservice?
For example, say that I show a UITableView with the information stored in Core Data, and then I would like to update the object.
Are there any design patterns or ideas for this?
Each time your app loads it should try to load info from the web service. If it can't connect, use the local data. You should timestamp your data on the server and in the app so that you can track when the information was last updated. You can also offer a button to manually refresh the data. (Like the Mail app.)
EDIT:
To make asynchronous requests, you can see the ASIHTTPRequest library.

How to develop iphone app with database?

I want to develop a CRM iphone app. I think there are 2 methods to deal with the data store, one is using the Sqlite(but it can not share datas with others ?), the other method is using the webservice(let the app CURD data by one web application), I want to know which is better?
I think the question is not about having one or the other, you could have both: Webservices to expose a central server somewhere where common data is stored and your local SQLite database where a copy of this data is stored. This allows you for fast search etc. instead of contacting some remote server that may or may not be on-line.
If you want to share your data then you have to store your data in webdatabase otherwise store in sqlite
you can store your data in sqlite for fast access and when you want to share that time you can send it to webservice and retrive when you need to see more data