bellotas
bellotas

Reputation: 2471

Unable to complete the operation while pushing a new controller

I am trying to navigate into a new controller, but I am getting the following error:

error The operation couldn’t be completed. (placesapi error 16.)

I have tried a couple of ways to do it, but the error persists.

Attemp1

self.navigationController?.pushViewController(MainViewController(), animated: true)

Attemp2

let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let mainViewController = storyBoard.instantiateViewController(withIdentifier: "mainViewControllerID") as! MainViewController
    self.present(mainViewController, animated: true, completion: nil)

The identifier of the controller is set as the image shows:

enter image description here

Solve

After cleaning my project and changing the name of the navigationController as Frankenstein mentioned, the navigation works. Note that cleaning was required.

Upvotes: 0

Views: 30

Answers (1)

Frankenstein
Frankenstein

Reputation: 16371

You need to give the story-board name and not the view-controller name:

let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let mainViewController = storyBoard.instantiateViewController(withIdentifier: "mainViewControllerID") as! MainViewController

Edit: Make sure your Main.storyboard file has a ViewController whose class is set as MainViewController and identifier is set as "mainViewControllerID"

Upvotes: 1

Related Questions