Variables and data losing scope when switching views
I've gotten this app so far, and now I'm running into a wall I didn't think existed.
Here's the hierarchy of my views...
Main Window
--TabViewController
----DrawingViewController
----SurveyManagerNavigationController
------SurveyManagerViewController
------SurveyListTableViewController
Basically, my main window has a tab view controller that holds the drawing VC and a management NC. The NC has two views, a main menu and a list of available surveys. The list appears when the user clicks a button on the menu.
The program works like this. I have a number of sqlite databases loaded into the application. Each one is a new survey that houses a number of drawings and other data. The DrawingViewController takes this information, displays it, and handles the actual work. The SurveyManagerNavigationController manages which survey is currently selected (ie which database to load the drawings with data).
When a user wants to work with a new survey, they hit the tab button to bring up the survey manager. Then, they tap the button to switch surveys, pick one from the SurveyListTableViewController, which takes them back to the manager, and then they can tab back to the drawing.
I have everything working except for the tabbing back. I have an NSVariable in my DrawingViewController that houses currentSurvey and another variable in my database shared instance class called surveyName. I have the code working so that if currentSurvey != db.surveyName, I want to reload all of the drawing data with new data. Effectively, I want to reload the entire DrawingViewController.
My problem is, when I go to that list of surveys and not choose a new survey, everything's fine. But when I do change it and the db.surveyName changes, the DrawingViewController's variable for currentSurvey says it loses scope, and all of a sudden, things crash.
This is a lot to try and explain, so I won't put down any code till someone asks for it. I really would appreciate the help. Thanks.
|