I am writing an iOS app with several (maybe 8) survey-style modules where the user will answer a series of questions (on Family Life, Health, etc.). Some modules have as many as 12 questions. Each question has its own nib and its own UIViewController. The answers will be written to a database, ideally, at the end of the module. Each module corresponds with one record in one table. There will only ever be one user, hence, one record. I want to leave the Core Data stack in the app delegate. I am currently creating Core Data objects from the View Controllers.
I have been struggling to find either:
- The best way to pass accumulating data down a long linear chain of UIViewControllers.
- An alternate solution.
I am aware of the following possibilities:
- Pass data data down the chain via overloaded initializers for the view controllers, using a collection that gets added to at each pass
- Pass data to a property in the child view controller, again using a collection
- Use global variables in the app delegate (I don't seriously consider this an option)
- Use singleton classes
I think singletons are considered the best option in this circumstance, at least in terms of design, but my research so far I haven't heard of anyone using so many (8, maybe more) singletons. The fact that they provoke so much argument confuses me. And I sometimes see multi-threading discussed along with singletons, but I have no understanding of why they go hand-in-hand (if they even do) and how I would handle that. Finally, if I were to use singletons, would I call the Core Stack from the singleton or from the view controller?
EDIT: Another question, if I use singletons, is - what do I do with my Core Data entity classes? Can or should I use the singleton classes to replace them?
Answers to the above and/or alternate suggestions for a solution would be greatly appreciated. If possible, I want to find a compromise between good design and easy/quick implementation. Changing the app design is not an option (the client is determining the layout and flow).