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
}
© 2025 OneMinuteCode. All rights reserved.