0

How to pass data from ViewController (VC) to MasterView (MV) in UISplitView? As I figured out I can't use segue because it goes from VC to SplitView, not to MV. Check please picture below

screenshot of storyboard

UPD:

Thanks Stepan for the help, I have figured out.

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "toMessurementVM"{
    let splitVC = segue.destinationViewController as! UISplitViewController
    let navVC = splitVC.childViewControllers.first as! UINavigationController
    let vc = navVC.childViewControllers.first as! MessurementTagsTableView
    vc.ingredient = passingIngredient
    }
}

I am not sure that this is right way, but it works. There are many examples of how to pass data from Detail to Master and vice-versa, but there is nothing for my case.

Thanks

Nikolai Prokofev
  • 184
  • 3
  • 14

1 Answers1

0

1) don't pass data! just use pointers.

2) you can get SplitViewController with superview from MasterView or ViewController

3) register for notification in controller you need and then just send notification that some data ready.

4) on destination controller which catch your notification - just get data with pointer with get superview from controller, cast it to SplitViewController and then you can get master or detail from it with no problems, and then get data from it by pointer.

5) use debugger stop and see what you have in superview, and then You will know exact how to act )

6) make sure to call all UI operation on main thread.

Stepan Maksymov
  • 2,618
  • 19
  • 31
  • Thansk for the answer, could you share some sample of code? – Nikolai Prokofev Oct 12 '16 at 00:34
  • just look in your controller for value `superview` in debugger, place breakpoint somewhere where you can see `self` in controller and you will se e what you can get ), how to make notifications - look stackoverflow - tons of samples. – Stepan Maksymov Oct 12 '16 at 01:24