skip to Main Content

I am making app for iOS and using Swift. When I open WebViewController from ViewController it works fine but the problem occurred when I click on the back button in the navigation bar to go back to ViewContoller. Then I get this error:

Inspection is enabled by default for process or parent application
with ‘get-task-allow’ entitlement linked against old SDK. Use
inspectable API to enable inspection on newer SDKs. 2023-09-25
09:24:14.668225+0530 all in one tools[11108:2951385] -[GUL_all_in_one_tools.AppDelegate-EFDEC20C-4D84-4E03-99AF-EE650765ECFE
window]: unrecognized selector sent to instance 0x2811c0de0 2023-09-25
09:24:14.670287+0530 all in one tools[11108:2951385] *** Terminating
app due to uncaught exception ‘NSInvalidArgumentException’, reason:
‘-[GUL_all_in_one_tools.AppDelegate-EFDEC20C-4D84-4E03-99AF-EE650765ECFE
window]: unrecognized selector sent to instance 0x2811c0de0’
*** First throw call stack: (0x1c22dd48c 0x1bb5bd050 0x1c243e424 0x1c4f07514 0x1c22f2700 0x1c235497c 0x10390d7bc 0x103c597a0
0x103c5b0e8 0x10390d734 0x10390f4dc 0x10390f3f4 0x102f6e380
0x102f6e3c4 0x1c427a9fc 0x1c469ff7c 0x1c4475744 0x1c43ac974
0x1c4453dbc 0x1c450000c 0x1c4a04d68 0x1c51cbfcc 0x1c433370c
0x1c43326c0 0x1c4331ecc 0x1c4331fcc 0x1c37819ec 0x103c597a0
0x103c6834c 0x103c67fa4 0x1c2365a2c 0x1c23496c8 0x1c234dda0
0x1f96bc998 0x1c45df80c 0x1c45df484 0x1ca561ddc 0x102f6ad4c
0x102f6acd4 0x102f6add0 0x1dfafc344) libc++abi: terminating due to
uncaught exception of type NSException
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason:
‘-[GUL_all_in_one_tools.AppDelegate-EFDEC20C-4D84-4E03-99AF-EE650765ECFE
window]: unrecognized selector sent to instance 0x2811c0de0’
terminating due to uncaught exception of type NSException

enter image description here

This is how I open WebViewController from ViewController

@IBAction func flipTextBtn(_ sender: Any) {
    let ViewController:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let desVC = ViewController.instantiateViewController(withIdentifier: "WebViewController") as! WebViewController
                                
    desVC.Title = "Title Here"
           
    self.navigationController?.pushViewController(desVC, animated: true)
}

2

Answers


  1. Chosen as BEST ANSWER

    i found the solution , just added

    var window: UIWindow?
    

    in AppDelegate and it works..

    thanks for help :)


  2. First of all

    self.navigationController?.pushViewController is not right method to use for go back.
    

    For go back, you just need to write below line

    self.navigationController?.popViewController(animated: true)
    

    If you want to go back to a specific UIViewController, then first of all, you need to find a particular UIViewController from the current navigation stack, and after getting a particular UIViewController, you can go back.

    Here is the example of how to go back to specific UIViewController

    guard let vc = self.navigationController?.viewControllers.filter({$0.isKind(of: WebViewController.self)}).first else {return}//get the specific vc
    self.navigationController?.popToViewController(vc, animated: true)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search