ios - NSFetchedResultsController - deleting rows - How to get access to managed object before row deletion? -
i'm using nsfetchedresultscontroller display core data , have user generated images in ubiquitous documents container, each managed object fetchedresultscontroller displays.
i've implemented swipe left delete functions on tableview, i'm having trouble accessing managed object before fetchedresultscontroller deletes object. need access delete user generated images in icloud container.
here's function i'm using:
func controller(controller: nsfetchedresultscontroller!, didchangeobject anobject: anyobject!, atindexpath indexpath: nsindexpath!, forchangetype type: nsfetchedresultschangetype, newindexpath: nsindexpath!) { switch type { case .insert: tableview.insertrowsatindexpaths([newindexpath], withrowanimation: .automatic) case .delete: tableview.deleterowsatindexpaths([indexpath], withrowanimation: .automatic) default: break } }
i've ran tests , can't reference deleted object using anobject, indexpath or newindexpath.
any assistance appreciated! thanks, garret
why controller responsible deleting data? if other controllers delete managed objects, have implement image deletion too? hardly solution.
i think make more sense intercept deletion in managed object subclass , make sure image deleted well. can use managed objects's preparefordeletion
hook.
Comments
Post a Comment