So after migrating my code to Swift 3 I now get errors with the following code designed to remove all data from Core Data. I have seen similar posts about this issue but none that seem to apply directly to how the code below works where I define the NSFetchRequest() without any parameters.
func removeAllChargerData(){
// Remove all charging data from persistent storage
let fetchRequest = NSFetchRequest()
let entity = NSEntityDescription.entity(forEntityName: "ChargerPrimary", in: self.secondMoc)
fetchRequest.entity = entity
let deleteRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest)
do {
try self.secondMoc.execute(deleteRequest)
} catch {
let deleteError = error as NSError
NSLog("\(deleteError), \(deleteError.localizedDescription)")
}
}
It now throws an error on the let fetchRequest
line stating: Generic parameter 'ResultType' could not be inferred.
Could someone explain what's changed here and how best to go about fixing it?
Thanks!