Now I have a server with many tables. In xcode, I use sqlite to store data from 1 table of server, so what should I do to connect and get data from server to store in slite db ?
You should have server side scripts ready for web services either REST or SOAP webservices.
Then, all you'll need to do in your iPhone app is use an NSURLConnection to fetch the URL. NSURLConnection is a very nice, asynchronous way of downloading files from remote locations.
After that, it's a simple matter of parsing the XML or JSON you can do that by using NSXMLParser
http://wiki.cs.unh.edu/wiki/index.php/Parsing_XML_data_with_NSXMLParser
NSJSONSerialization
http://www.raywenderlich.com/5492/working-with-json-in-ios-5
or third party api's
Once you have sorted out the required data you can save it in sqlite db in your device
This link should get you some idea about sqlite
http://www.raywenderlich.com/913/sqlite-101-for-iphone-developers-making-our-app
Hope it helps :)
Related
I am looking at trying to create an app the takes information provided from databases from stores and transfers this data to the app (into a spreadsheet or useable data form of some kind) and then be able to use this data within the app.
This data will also need to be able to be updated.
These are the thing I need to know
How to access these servers and retrieve the data at will
How to store this data for the app to use
If someone could please direct me to a series of tutorials about this sort of thing or provide some information that I can google and find out about that would be ideal.
Thanks
You don't need to learn tutorials if you know all about HTTP and Swift well. Well, I can provide you some fast way that you can learn
For HTTP Services :
REST Web Services => Alamofire
SOAP Web Services => Handling SOAP request using NSURLSession
If you use those, I am sure that you can do HTTP Request easily.
So, as soon as you get the response data from HTTP Request, you will have to parse it, JSON or XML.
For response parsing :
JSON : Swifty JSON : which can handle JSON more easy way
XML : SWXMLHash : which can let you handle XML easy way
So, as soon as you can parse JSON or XML that you get from HTTP request, you need somewhere to store it right? You can use SQLite Database or Realm. So, you can store it and get it back anytime you need at your local devices application memory storage.
For storing and getting result data from database:
Realm Swift : Realm ORM Database : which is easy to learn and useful and quick
These are all the Info you need. Displaying the data is based on your design theory.
For further more reading :
Alamofire Beginner Guide : AppCoda
Parsing Data and Swifty JSON : HackingWithSwift
Realm swift learning its documentation
There are many tutorials around the www.google.com all you have to do is need to ask at the search box.
Let's say there I have an app that has model structure "Teams" and it's respective "members". This app then pulls data from a web service in json. How does the web service communicate which data has changed and how?
I'm thinking it passes certain JSON keys to notify the app which kinds of updates have occurred. For example:
{"operations": [{"delete":"member1"}, {"add": team2}, {"rename": team3} ... ]}
What are the conventions of doing this?
Edit 1: I am not looking for frameworks that solve this problem. I just want to conceptually know how this is usually done.
Generally the app will ask the server: "What has changed since XXX" and the server will reply with the objects that have changed since that date. The server generally gives full objects for the app to parse and consume.
With that assumption you can get the response from the server and then walk the objects in the JSON payload, loading objects that exist and updating them and then inserting new objects that do not exist locally.
Deletes can be more challenging as most servers that I have seen won't tell you about them. If you control the server then you could send a response with identifiers to objects that have been deleted since the last update.
I am a beginner to ios development.
Can anyone tell me how to send data to server in xcode?
I have a requirement where I need to send device information to a server.
You need to first work out what kind of API the server you're talking to has exposed
Most modern web applications expose a Rest API (although I can only speculate as to what the server you mention is exposing). If Rest, then a good starting point should you not wish to write your own network layer is to use Restkit: https://github.com/RestKit/RestKit
If not Rest, then you need information on what the backend API is, and then go from there...
In it's most basic format you'll need to look at using NSURLRequest and NSURLConnection
NSURLRequest : Post data and read the posted page
http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/
When using RestKit, can I embed in my app a service response (as a JSON file) so when the app fails (offline use) or the web service fails (server fails or just plane mode)? can I use that embedded data?
I would like to reuse the mapping and the request so it's easier to program the UI.
Can RestKit do that?
Any idea or suggestion? Reading the docs or issues I don't see anything.
You should not really do this with JSON, you should use a seed to your Core Data database.
If you aren't using Core Data or you want to use JSON then you can create a new object manager, with the same mappings, and with a base URL which is a file URL (pointing to your folder containing your JSON files on disk) to load and process them.
I am working on an application for iOS which needs to synchronize data between multiple users and one web server.
I did some research and the best solution I found for this is working with JSON.
At the moment I have a .json file on a web server and I am able to download the data to my iphone app and parse it.
I have two problems I didn't manage to understand yet:
1. How can each iphone user write back data to the json file on the server?
2. How can I take a data table and automaticly convert it to a .json file? so the .json file on the server will be updated every few minutes or so...
I'll appreciate any help with this!
You dont send JSON file as afile to the devices, you send a JSON request, I advice to do more reading about this topic, you can start from below:
Working with JSON in iOS 5 Tutorial
enter link description How to make HTTP request from iPhone and parse JSON result
How to fetch and parse JSON by using data models
and read this SO question:
iPhone/iOS JSON parsing tutorial
How to sent JSON request in the Post method in iPhone?
How to send json data in the Http request using NSURLRequest