Core data not being delete permanently through protocol function

My code is trying to delete a element from a set via button. When the user presses the button the set is deleted from that page but if it is reloaded the code is still there. So it is not permanently deleted. All I am doing is trying to delete a element from the core data set. I save the code in one class and iand display it through another. Link to git core-Data-Delete/photography at master · redrock34/core-Data-Delete · GitHub.

extension ViewController : datacollectionProfotocol {
 func deleteData(indx: Int) {


let date = users[indx]

users.remove(at: indx)
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDelegate.persistentContainer.viewContext
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Item")

request.predicate = NSPredicate(format:"atBATS = %@", date as CVarArg)

let result = try? context.fetch(request)
let resultData = result as! [NSManagedObject]

for object in resultData {

do {
    print(" saved!")
} catch let error as NSError  {
    print("Could not save \(error), \(error.userInfo)")



@timswift Do you still have issues with this?

This topic was automatically closed after 166 days. New replies are no longer allowed.