0

How to implement an appdelegate in own framework class?.Because i have to detect when app is entering to foreground/background. Ex: like, in android Applifecycle run in service class

  • There a equivalent notifications for that which you can listen to. – HAS Nov 14 '17 at 08:00
  • Does this help? https://stackoverflow.com/questions/24910765/ios-nsnotificationcenter-to-check-whether-the-app-came-from-background-to-foregr – HAS Nov 14 '17 at 08:01

1 Answers1

1

You can create your own App Delegate class by simply implementing the UIApplicationDelegate protocol:

@UIApplicationMain
class CustomAppDelegate: UIResponder, UIApplicationDelegate {}

Note you will have to implement the various app delegate methods in this class.

EDIT:

In order to call this from another class you can cast the appDelegate singleton as follows:

if let appDelegate = UIApplication.shared.delegate as? CustomAppDelegate {}
ZeMoon
  • 20,054
  • 5
  • 57
  • 98