I want to get the currently active UIViewController from AppDelegate

Asked 2 years ago, Updated 2 years ago, 38 views

I would like to know which UIViewController is currently active to use Notification


for Objective-C [self.window.rootViewController presentedViewController];
It was written that you can check in
How can I check it with swift?
Either StorybordID or title is fine

swift xcode

2022-09-29 21:12

1 Answers

If you simply convert the code in the question to Swift, it looks like this.
(Use from inside AppDelegate)

iflet vc=window?.rootViewController?presentedViewController{
    // The vc contains a UIViewController
}


2022-09-29 21:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.