I am going to display list of cities and countries. I have to get it from server using web service. but city and country are not changed every time. so we don't need to call that web service every time. so we can store all the information locally. what is the best way to handle this situation?
Asked
Active
Viewed 64 times
0
-
there are lots of ways.. but probably quickest is to use `NSUserDefaults` – Fonix Dec 23 '15 at 08:43
-
You can choose CoreData for local storage. [http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started](http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started) – Gandalf Dec 23 '15 at 08:44
-
add the city and country list to a json file and add it to your project. because you may need that list in other project than it will be easy to dan and drop the files in another project – Smile Dec 23 '15 at 08:47
-
i suggest you to add list to json file and use it in project instead of Coredata, Userdefaults or Plist it is pretty easy – Smile Dec 23 '15 at 08:49
-
You can store that file(response from web) in documents directory. – Mehul Sojitra Dec 23 '15 at 09:15
3 Answers
0
Yes you are right we don't need to call web service every time. You can use coredata in this situation. Using coredata you can manage all data locally and retrive back from coredata.
Core Data is the best one to use for non-trivial data storage. It can reduce the memory overhead of your app, increase responsiveness, and save you from writing a lot of boilerplate code.
Refer this link : http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started

Ekta Padaliya
- 5,743
- 3
- 39
- 51
0
There is some more option to locally
1. Using LocalDB - its little bit pain but not bad that much
2. Using XML file - you should have the method to retrieve the data.Its pretty easy
3. Using Plist - This is also very easy can done through few lines.
4. NSUserDefaults - This can be use only as few cases like User information, store tokens.
Got it!

S. Karthik
- 618
- 5
- 16
0
You can do this in several ways
- you can use nsurl session caching
- store data in local db (coredata or sqlite) http://www.raywenderlich.com/934/core-data-tutorial-for-ios-getting-started
- For simple data you should use NSUserDefaults
- use plist file http://www.theappcodeblog.com/?tag=ios-saving-data-to-plist-tutorial
http://code.tutsplus.com/tutorials/ios-sdk-working-with-nsuserdefaults--mobile-6039
please check the following also

Community
- 1
- 1

Anshad Rasheed
- 2,526
- 1
- 14
- 32