Я пытаюсь удалить одну запись из базы данных.Swift - удалить одну запись из базы данных
if let items=fetchedResult{
print(items.count) //this always prints "1", so it's working well
for item:NSManagedObject in items{
println(item) //this prints the only element found. Also working well
println(sender.view!.restorationIdentifier!) //the restorationIdentifier matches with the id from the object in the database. Also working well
managagedContext.deleteObject(item) //<-- THIS is what is not working
sender.view?.removeFromSuperview() //removing the view well
}
}else{
print("Could not delete \(error), \(error!.userInfo)")
}
Как сказано в комментариях, линия managagedContext.deleteObject(item)
не работает, я не получаю ошибку, она просто не удаляет объект в базе данных.
Я искал 2 дня и ничего не нашел. Я надеюсь, что вы можете мне помочь.
Спасибо.
Вы сохранили контекст после удаления? – zisoft