mercredi 7 janvier 2015

why the file in core data still there although i can delete object successfully in core data

i try to delete the row in tableview and delete the core data like this:



func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {

if editingStyle == UITableViewCellEditingStyle.Delete {

context.deleteObject(sounds[indexPath.row] as NSManagedObject)
sounds.removeAtIndex(indexPath.row)
context.save(nil)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)

}
}


with context = UIApplication.sharedApplication().delegate.managedObjectContext! and sounds is my Array which store the objects in core data.


i can delete the row and delete the file in core data successfully. i can check it because after i delete the row, i re-run my app again and the data is really deleted and does not appear on my tableview. But when i check the documents folder of my app in simulator. I still saw that data with some sqlite file. Why the file still in that folder? and how can i delete that? if you want to check my code , you can download here from my dropbox, it only 439KB http://ift.tt/1xFqTew


Aucun commentaire:

Enregistrer un commentaire