Link to home
Start Free TrialLog in
Avatar of englishchrissy
englishchrissy

asked on

Best way to pass data between 2 views

I am writing an app with a tab bar with 4 tabs, each tab has a navigation controller to control the views. The first tab is my home view which has a button in the navigation bar that when tapped takes you to the details view. The details view has a back button to take you back to the home view. So for the first tab bar it is like this:

                                                Tab Bar Item 1
                                                          |
                                       HomeNavigationController
                                      /                                          \
                     HomeViewController                  DetailsViewController

At the moment I get data from the database in the HomeViewController and display it in the HomeView. You can then tap a button in the Navigation Bar that takes you to the DetailsView. I'm having trouble accessing the data I got in the HomeViewContoller from the DetailsViewController as it is then out of scope.

Can someone please advise me as to what I am doing wrong. I know the solution will probably be easy and that I'm doing something stupid. I am new to iphone app development and oop programming so please be gentle.

Should I put all the database access code in the HomeNavigationController so that the 2 subordinate views can access that info? I'm trying to work out the best approach but would like some advice before I start tearing my programs apart as they are very nearly working now.
Tags:
SOLUTION
Avatar of SpeedyApocalypse
SpeedyApocalypse
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of englishchrissy
englishchrissy

ASKER

Opps, See my comment above. Cheers