0

I want pass value to my viewcontroller and keep my navigation flow.

I have created navigationController which opening my PostJobVC.

When I am calling this it's working but navigation not working.

  let vc : PostJobVC = UIStoryboard.instantiateController(forModule: SFStoryBoard.job)
        vc.history = history
        self.navigationController?.present(vc, animated: true, completion: nil)

For that reason I am opening navigationController (name is jobnav)

let storyboard = UIStoryboard(name: SFStoryBoard.job.rawValue, bundle: nil)
        let controller = storyboard.instantiateViewController(withIdentifier: "JobNav")
        self.present(controller, animated: true, completion: nil)

How could I pass history object to PostJobVC through JobNav automatically.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
pmb
  • 2,327
  • 3
  • 30
  • 47
  • u need to subclass the navigation controller and pass data to that class! – Teja Nandamuri Aug 11 '17 at 14:22
  • @TejaNandamuri I didn't understand could you please put some code here? – pmb Aug 11 '17 at 14:25
  • 1
    You pass data from the view controller that pushes the new view controller. It's not the Navigation Controller's job to be an intermediary for data transport between controller's in it's stack. – Abizern Aug 11 '17 at 14:41

1 Answers1

-1

Subclass navigation controller, and pass data to that controller:

var navCon: MyNavigationController? = storyboard.instantiateViewController(withIdentifier: "")

Declare a property:

 var dataToSend: String = ""

you can send data to dataToSend

navCon.dataToSend = "hello"

In the MyNavigationController, you can later pass on this value to any of the view controller in the navigation stack.

Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109