Is it possible to conform to UIApplicationDelegate
and successfully have all of the functions that are called on startup/close called in ANY class? For instance, if I have a class where it would be a good idea to save a lot of data on the app's closing, but I don't want to create a reference to it in the App Delegate, would it be OK to just have it conform the the UIApplicationDelegate
protocol, then perform it's save in (void)applicationWillResignActive:(UIApplication *)application
?
To be more succinct: is there any danger in having multiple classes conform to UIApplicationDelegate
?
Only one delegate can be designated for any object at any one time. It sounds like what you really want to do here is register for notifications.
Or, if there are no notifications for the things you want, set your application delegate to post custom notifications to any listeners in all the various classes you want to do work when certain app delegate things get fired.
And to answer your succinct question, there shouldn't be "danger" in having multiple classes conform to UIApplicationDelegate
, but again, you can only have one delegate answering to UIApplication
at any one time.