maybe im not asking the right question, or maybe is not what i really need but the thing is in my app I have 2 Viewcontrollers, the first one with a picker view where you can find cities, you chose one and then you press a button that takes you to the second view controller, there you have and other picker view that shows you places according to what city you had chosen, but my problem is that I have a Label (in the second controller) that should show what you choose, so i think i must use different 'ifs' according to the place you have chosen, but it has to depend also on what did you chose on the first view controller and there is my problem, i don't know how to go forward with this. Hope someone has an answer for that. Im using Swift.
Asked
Active
Viewed 43 times
0
-
1possible duplicate of [Passing Data between View Controllers in Swift](http://stackoverflow.com/questions/24222640/passing-data-between-view-controllers-in-swift) – timgcarlson May 21 '15 at 19:35
-
You may want to go through a few iOS tutorials to see how to persist/pass data throughout the application. – TheCodingArt May 21 '15 at 19:53
1 Answers
0
Sounds to me like you're using a master/detail design. On the first view controller you pick a city. That sends information about the selected city to the second view controller.
In the second view controller you'll look up the data to display for the selected city, and use that city-specific info to populate a picker (and anything else you need.)
You can either store your data for all cities in a global model and simply pass a city index to the second view controller, or you can have the first view controller "peel off" the data for the user's selected city and pass that data to the second view controller.

Duncan C
- 128,072
- 22
- 173
- 272