iambot iambot - 2 years ago 70
iOS Question

In layman's terms, how should I use appdelegate file in buliding an iOS app?

It seems there is no good definitive and useful explanation on this other than extensive, jargon-filled ones.

Answer Source

In layman's terms, the app delegate file is best used for catching (and then doing something in response to) important app related events, like:

applicationWillResignActive: (Called when leaving the foreground state.)
applicationWillEnterForeground: (Called when transitioning out of the background state.)

You can have your app do whatever it needs to do whenever iOS tells your app these things are happening. For example, do you need to save a current game state when the phone is getting an incoming call, that's where you implement your own applicationWillResignActive method.

Other developers will also sometimes put code that doesn't easily fit into subclassed view controllers into the app delegate file, but as you improve your iOS programming skills you'll find there's plenty of other places (and other ways) to save & handle non UI related functions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download