I have a UIViewController
called BaseController
, this controller holds all the functionality of the screen, download data from service and more...
I'm currently inside a UIViewController
called HomeVC
which inherit from BaseController
, when initialize this UIViewController
I'm calling a method to download the data from service, after downloading the data, I insert the data (lets call the object DbHomeData
) into CoreData
and display it in a UITableView
on HomeVC
.
My problem occurs when I click on one of the UITableView
cell's, it pushes a new UIViewController
that inherit also from BaseController
.
This new UIViewController
is downloading new data and insert it once more to CoreData
as the HomeVC
is doing, but now I have the old data and new downloaded data together, but if I will remove the old data, then when I pop this UIViewController
, the old data will be gone and the UITableView
will display nothing.
How can I workaround this issue or fix it? Is there a way to initialize NSManagedObject
without inserting it into CoreData
? Is there a better solution?
Thanks in advance!