0

I have a viewcontroller showing the detail of a book. What I want to do is saving data to database in a background thread before the viewcontroller is poped from the navigationcontroller.

I don't know where to put the logic save data to database, viewWillDisappear or deinit are the right choices?

Nhu Nguyen
  • 187
  • 1
  • 3
  • 15
  • Yeah, because I save data to database on mainthread can block my UI. Is there any way to keep viewcontroller alive until saving data is completed? – Nhu Nguyen May 16 '20 at 10:01

1 Answers1

0

I think you just need to create a global service which call to do anything you want to save. Then call it with data in your viewDidDisappeared()

King.lbt
  • 843
  • 5
  • 15