3

I have an application that uses a UITabBarController to setup two other controllers that both need access to the same model object. Could anyone give me any information on how to best implement this. My initial thought was to use a shared instance (singleton) that I could access from both, but I am just curious if I am missing a better method?

fuzzygoat
  • 26,573
  • 48
  • 165
  • 294

1 Answers1

2

I usually create my model as a singleton. It brings convenience but could also come with the temptation of accessing it from the views which break the MVC paradigm. Passing the model to every controller is probably the safier way.

You can find good tips on creating singletons with objective-C in this article

I have saw some developers put it as a property on the applicationDelegate but the model definitely don't belong there.

I vote singleton !

Community
  • 1
  • 1
VdesmedT
  • 9,037
  • 3
  • 34
  • 50