Hi guys, I'm having some problems with core data. I want to delete everything, but nothing is working and the size of the app is increasing. I'll share with you the code that I've implemented. Can you help me solving this?
Code Block swift func deleteAllData(_ entity:String) { let appDelegate = UIApplication.shared.delegate as! AppDelegate let persistentContainer = appDelegate.persistentContainer let managedContext = appDelegate.persistentContainer.viewContext let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: entity) let DelAllReqVar = NSBatchDeleteRequest(fetchRequest: fetchRequest) fetchRequest.includesPropertyValues = false do { let results = try managedContext.fetch(fetchRequest) for object in results { guard let objectData = object as? NSManagedObject else {continue} managedContext.delete(objectData) try managedContext.save() } managedContext.reset() try managedContext.execute(DelAllReqVar) try managedContext.save() } catch { print(error) } }