0

I'm a newbie learning swift programming on iOS. I have a small app with 3 views embedded in a navigation controller. I have some country data (150 countries total, each country record containing 10 fields) that I want to display in part on the 3 separate views.

FirstView: Show country record about current location (location obtained by GPS) SecondView: Show listview of all countries (all 150 records) ThirdView: Show the ten fields of selected record of SecondView

My question is: What is the best method that I should pursue to share data between the three views?

Presently, I'm using an array of tupples to display all 150 records in the SecondView. I then pass the selected record from the 2nd view controller to the 3rd view controller by segue. But I'm not sure how to share the data defined in the array (the array is presently defined on the SecondView controller) with the FirstView controller. Should I use CoreData? Or parse a CSV file? Or define the array in the FirstView controller?

The database will stay unchanged, users will only browse the data, not add anything to it.

Any help on which method should be used would be greatly appreciated. I've been looking online, but really not sure which method should be used.

Thank you!

;-) Louis.

  • Welcome to Stack Overflow! Please describe *precisely* what you tried and make sure to show some code. General questions like this may be seen as "too broad" or "primarily opinion-based" and, as a result, may be eventually closed. – akashivskyy Jan 07 '15 at 20:18

1 Answers1

0

As @akashivskyy said: you question is too broad. But in general you can query any database at reasonable speed. The easiest is probably to use SQLite since you can use standard libs: Accessing an SQLite Database in Swift

Community
  • 1
  • 1
qwerty_so
  • 35,448
  • 8
  • 62
  • 86