Core Data Quickest way to delete all instances of an entity swift
public func clearDatabase() {
guard let url = persistentContainer.persistentStoreDescriptions.first?.url else { return }
let persistentStoreCoordinator = persistentContainer.persistentStoreCoordinator
do {
try persistentStoreCoordinator.destroyPersistentStore(at:url, ofType: NSSQLiteStoreType, options: nil)
try persistentStoreCoordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil)
} catch let error {
print("Attempted to clear persistent store: " + error.localizedDescription)
}
}
}
Also in Swift:
- swiftui background color
- xcode how to get aspect ratio of device
- verilog monitor
- swift out of bound elelemnt
- how to change background color of stackview swift
- displaying button title swift stackoverflow
- swift ternary statement
- swift open url
- how to swift pie chart quartzcore framework
- swift uitableview insert cell
- swift show title on navigation bar programmatically
- xcode how to know which textfield is selected
- fnb swift code
- swift list
- if statement swfit
- swift uitextfield only numbers keyboard lock programmatically
- swift close app
- swift switch
- limit log file size swift
- .next() enum swift
- Split a String into an array in Swift
- swift get day from available string
- IOS create UIAlertViewController programmatically
- swift remove tableview cell