i have tableview
based app core data
. each cells deletable , works pretty cool, nsfetchedresultscontroller
, delegate
protocol methods. want cancel specific uilocalnotification
instances while specific cell deleted. core data
contains of information of uilocalnotification
, userinfo
included. i'm stopped here. can tell me? if it's possible or should use nsuserdefaults
instead of core data
?
here's i've done. it's seems works properly, don't know it's correctly or not
` override func tableview(tableview: uitableview, commiteditingstyle editingstyle: uitableviewcelleditingstyle, forrowatindexpath indexpath: nsindexpath) {
if editingstyle == .delete {
let delete = self.fetchedresultscontroller.objectatindexpath(indexpath) as? nsmanagedobject let cell = tableview.cellforrowatindexpath(indexpath) notification in uiapplication.sharedapplication().scheduledlocalnotifications! { if (notification.userinfo!["givenname"] as? string == cell?.textlabel?.text) { uiapplication.sharedapplication().cancellocalnotification(notification) break } } self.managedobjectcontext.deleteobject(delete!) // delete action { // save action try self.managedobjectcontext.save() // save action } catch { // error } } }
`
thanks