F
F
FlooDwm2016-11-01 10:34:51
iOS
FlooDwm, 2016-11-01 10:34:51

Executing a function before the ViewController is loaded?

The point is this. When you click on a cell, a function is executed that saves to UserDefault

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let download = DataData() //DataData class to download data
        download.DownloadData(id: id[(indexPath.row)]) // func download data in DataData class
    }

Then a transition is made to another controller where UserDefault is checked in viewDidLoad.
But it's not filled. those. order is not followed. Why did I save UserDef before loading the new controller

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
ManWithBear, 2016-11-01
@ManWithBear

Because for the transfer of data between controllers using userDefaults, you need to kick.

V
Vladislav Pavlenko, 2016-11-02
@pavlenkovs

at you transition is carried out through segue or in didSelectRowAtinex... a method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question