0

I have the array of country list data , which having the three keys, like countryCode, countryName, CountryId. Now i have to integrate that array in such a way so that, My app get the Country list data saved with in the app. It can be access without internet, without any API called.

I have used the way to save that array by using Core-Data, but i need internet to connection first time to get the country list array.

But i Need to Integrate in such a way so that it can be saved when i installed my app.

Need your suggestions

Thanks

MayankSengar
  • 284
  • 5
  • 19
  • 2
    Best way to use .plist file for add those data and display in your app – iPatel Nov 10 '17 at 07:26
  • 1
    https://stackoverflow.com/questions/46232452/list-of-countries-and-country-dialing-codes-country-name-and-country-icon-obje/46232622#46232622 – karthikeyan Nov 10 '17 at 08:16

2 Answers2

0

I have a suggestion for you.

  • Save the country list to a file such as .plist file (@iPatel suggested) or .json file and put it to your app.
  • At the first time app launched, in didFinishLaunchingWithOptions check your data file and save data from this file to your Core Data. If it doesn't have internet connection, you still can get country list from Core Data to use.
  • When having internet connection, check API and update country list in Core Data if needed.
trungduc
  • 11,926
  • 4
  • 31
  • 55
0

You have multiple Options:

  1. As like as @trungduc and @iPatel suggested you can use pList or JSON.
  2. Sometimes plist is not preferred from architects they want CoreData. then create a sqlite file bundle it in your app and replace the same on app launch with the once created by CoreData itself.

Check with requirements, what if you need to change data on live apps? then implement logic to fill data dynamically as well. The above two ways won't allow you to change data on live apps. Service call and filling data with service call will allow you to change data whenever you want without any new release.

Rishi Chaurasia
  • 520
  • 4
  • 18