I am making an iPhone application that goes through a set of viewcontrollers that collect data from user input. At the end of the views I encapsulate all of the data in an customized object called GELObject. Now I need to save this data in a NSMutableArray somewhere so that it can be accessed by a tableviewcontroller that is another branch off of the rootviewcontroller. I was thinking a global variable from the tableviewcontroller, but I did some research and I am reading about singleton’s in the appdelegate. Some guidance would be greatly appreciated and if you’re feeling extra generous a quick explanation of how to make and use singleton’s because it is intriguing me.
Thanks!
I am making an iPhone application that goes through a set of viewcontrollers that
Share
To manage a singleton you create a global variable (can be restricted to one file’s scope with
static) with an initial sentinel value ofnil, and use a class method to create the singleton on the first call.For example: