MacSergey MacSergey - 1 year ago 45
iOS Question

how send data to new view

please help. I need send data from view to new view. I have that 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

is NavigationController, not my TableViewController

Answer Source

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