To remove an existing record from CoreData
in Swift, you can follow these steps:
deleteObject
on the managed object context.save
method.Here is the sample code to remove an existing record from CoreData:
main.swift407 chars13 lines
In this code, fetchedResultsController
is an instance of NSFetchedResultsController
that fetches records from CoreData
. indexPath
parameter is the index path of the record that you want to delete.
Note: Don't forget to handle the errors when saving the changes to the managed object context.
gistlibby LogSnag