MacSergey MacSergey - 5 months ago 9
iOS Question

how send data to new view

please help. I need send data from view to new view. I have that StoryBoard.
StoryBoard

In first view i have code

override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "LEDChangesSegue" {
let changeLED = segue.destinationViewController as? AddLED
changeLED?.senderCell = sender as? LEDListCell
changeLED?.ledController = sender!.ledController
changeLED?.update = true
}
}


this method worked when I use push segue, but now I use modal segue and in
segue.destinationViewController

is NavigationController, not my TableViewController

Answer

Use the new destination as VC to call your next tableViewController

let destination = segue.destinationViewController
if let navcon = destination as? UINavigationController {
    destination = navcon.visibleViewController!
}
if let hvc = destination as? TableViewController{
   // do whatever
}