Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete all the objects from encrypted core data #322

Open
Rahul0106231 opened this issue Jul 25, 2019 · 3 comments
Open

How to delete all the objects from encrypted core data #322

Rahul0106231 opened this issue Jul 25, 2019 · 3 comments

Comments

@Rahul0106231
Copy link

i have a requirement when a new user logs in to the device which is already registered to another user . i need to delete all the data pertaining to the previous user present in coredata.
i'm using batch delete to perform the operation , but it throws an error . here's the piece of code i'm using to delete the objects.Is there a prescribed way to delete all the entities in coredata in quickest way possible..

do {
try self.persistentContainer.managedObjectModel.entities.forEach { (entity) in
if let name = entity.name {
let fetch = NSFetchRequest(entityName: name)
let request = NSBatchDeleteRequest(fetchRequest: fetch)
try self.viewContext.execute(request)
}
}
self.saveMainContext()
}
catch let error as NSError{
DDLogError("Could not Reset The Database (error.userInfo)")
}

@chadbag
Copy link

chadbag commented Sep 5, 2019

We had to get rid of the NSBatchDeleteRequest, IIRC, and fetch all the data and delete it in a loop (like you had to do before the batch delete was available).

@glaurent
Copy link

It seems batch requests are not supported :-/

@aomsir
Copy link

aomsir commented Oct 27, 2024

There seems to be no support so far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants