Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Calling SceneDelegate method from ViewController

Tags:

ios

swift

I tried following code to call Scene Delegate func from a VC and getting error

Thread 1: signal SIGABRT

 let sceneDelegate = UIApplication.shared.delegate as! SceneDelegate
 sceneDelegate.initializeFirstViewController()

Is there any way i can call SceneDelegate func from VC?

like image 987
iamjpsharma Avatar asked Dec 10 '25 04:12

iamjpsharma


1 Answers

UIApplication.shared.delegate is AppDelegate not SceneDelegate You need

if let scene = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate {    
   // to do 
}
like image 194
Sh_Khan Avatar answered Dec 11 '25 18:12

Sh_Khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!