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
Asked
Active
Viewed 738 times
0
-
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 Answers
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
-
-
Could not cast value of type 'FrameworkTest.AppDelegate' to 'WalinnsTracker.TrackerDelegate' . "FrameworkTest " tis is app delegate, " "WalinnsTracker " inside of framework – RejoylinLokeshwaran Nov 23 '17 at 11:52