Save data to database before viewcontroller deallocated

56 views Asked by At

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?

1

There are 1 answers

0
King.lbt On

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()