Search code examples
swiftsegueviewcontroller

how can i pass data using dismiss?


I have two viewControllers A B

I go A to B using performsegue and DataPass A to B using prepare().

segue kind is Show.

if segue.identifier == "toWrite"{
            let vc = segue.destination as? WriteViewController
            vc?.diary = Date[Date.count-1]
            vc?.made_content = made_content
            vc?.presentIndex = Date[Date.count-1].presentIndex
            vc?.presentIndex = sendIndex
        }

but when I go B to A, I want pass B Data to A

I can't do this\


Solution

  • An other way it’s to use protocole and delegate which is very common.

    I’ll recommend you this link, to have a good start

    https://learnappmaking.com/pass-data-between-view-controllers-swift-how-to/#back-properties