0

In my app i have several "Managers" objects that handle stuff for me, for example:

  • FacebookManager - handle all the Facebook methods of my app
  • ApiManager - handle all our product API connection method
  • etc..

All those managers should be initialise at when the app starts and terminated once the app is terminated.

Naturally because the AppDelegate handle the start and end of my application i thought to put those instances there, so all other's app's part will have a way of getting them as needed. Is it a good practice or should i use the app delegate to assign a single-tone in a static variable for each of the managers ?

Asaf Nevo
  • 11,338
  • 23
  • 79
  • 154
  • Possible duplicate of [How or where should I store object instances that I require globally within my iOS app?](http://stackoverflow.com/questions/5721990/how-or-where-should-i-store-object-instances-that-i-require-globally-within-my-i). Also see [Where to store “global” objects in iOS](https://stackoverflow.com/questions/11546257/where-to-store-global-objects-in-ios). – jww Aug 27 '14 at 09:14
  • I guess better to have one singleton class, which has all such manager instances. Alloc-Release that singleton class object from AppDelegate as you mentioned and use all your managers using that class object throughout the application. Also if you use ARC then there is no need to terminate/release those objects at app exit event. – Mrunal Aug 27 '14 at 09:14
  • Neither, pass them along to view controllers or instantiate them as necessary. – quellish Aug 27 '14 at 09:14
  • @quellish so for each view control to initiate a new manager? isn't it inefficient ? – Asaf Nevo Aug 27 '14 at 10:04

0 Answers0