1

Yes we all know navigationController?.pushViewController(vc, animated: true) used for pushing controller. I want to ask is there any way that we can jump to ViewController on debugging?

For ex. -

func jump() {
   let vc = ViewController(nibName: "ViewController",bundle: nil)//here breakpoint set
   //navigationController?.pushViewController(vc, animated: true)
}

can we uncomment pushViewController dynamically (using debugging or any technique.)?

Ramesh
  • 147
  • 1
  • 17

2 Answers2

1

yes you can use,

  1. place a breakpoint at let vc = ViewController(nibName: "ViewController",bundle: nil)//here breakpoint set
  2. click the "Next" button for debug and in debug window paste this line using po command and press enter. po navigationController?.pushViewController(vc, animated: true)

and now press the play button of debugging..it will execute your code.

MAhipal Singh
  • 4,745
  • 1
  • 42
  • 57
0

For the second part of your question: You can use compilation conditions to only execute the command in certain targets. Like in the MyApp-Debug you would do it but in MyApp-Release the code woulnd't be executed.

#if DEBUG
    navigationController?.pushViewController(vc, animated: true)
#endif

Refer to this thread for more detailed information: Swift: how to use PREPROCESSOR Flags (like `#if DEBUG`) to implement API keys?

TMob
  • 1,278
  • 1
  • 13
  • 33