I’m building an app that uses a TabBar controller in which one of the view controllers an NSMurableArray is set (and potentially modified). I then need to use that same array to populate a table on one of the other views when it is selected. I’ve looked into using a singleton (as was provided as an answer to this question on this website already) but haven’t had much luck.
Would a singleton be the best way to go or is there a better way of doing it? I’d appreciate any help/examples if possible?
You have several options for doing this, here are 2…
1.) have the NSMutableArray be a property of the one view controller so the other one can access it like
viewController1.mutableArray. To do just add@property (nonatomic, retain) NSMutableArray *mutableArrayto your viewController class (using whatever name you want).2.) Pass the array through a method from the first viewController to the other and keep a reference to that array in the other class.