I am a little confused as to how to delete all core data in swift. I have created a button with an IBAction linked. On the click of the button I have the follow
An alternative can be to completely remove and recreate persistent store (iOS 10+, swift 3).
let urls = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask);
var dbUrl = urls[urls.count-1];
dbUrl = dbUrl.appendingPathComponent("Application Support/nameOfYourCoredataFile.sqlite")
do {
try persistentContainer.persistentStoreCoordinator.destroyPersistentStore(at: dbUrl, ofType: NSSQLiteStoreType, options: nil);
} catch {
print(error);
}
do {
try persistentContainer.persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: dbUrl, options: nil);
} catch {
print(error);
}