0
UIを使用してコアデータエンティティを削除および編集する機能があります。変更はUIで機能しますが、ビューに戻るときは変更されません。私は、何も起こらないセービングを引き起こしたものを逃したと確信していますが、それを理解できません。それは、標準のセーブ・スローを追加して、削除関数の最後にキャッチする場合に過ぎませんか?それは私にアンラッピングエラーを与えない限りですか?または!エンティティを変更するときにコアデータが永続する問題
を使用している私は、関数たとえば、スイッチケースが含まれている:
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch (type) {
case .insert:
if let indexPath = newIndexPath {
workoutDesignerTable.insertRows(at: [indexPath], with: .fade)
}
break;
case .delete:
if let indexPath = indexPath {
workoutDesignerTable.deleteRows(at: [indexPath], with: .fade)
}
break;
case .update:
if let indexPath = indexPath, let cell = workoutDesignerTable.cellForRow(at: indexPath) as? RoutineTableViewCell {
configure(cell, at: indexPath)
}
break;
default:
print("...")
}
}
削除FUNCに
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Fetch Exercise
let UserExercise = fetchedResultsController.object(at: indexPath)
// Delete Exercise
UserExercise.managedObjectContext?.delete(UserExercise)
}
}
のように、この答えを何かが必要だと思いますありがとう! – infernouk