在CoreData
中,Quote
和Image
之间存在一对多的关系。 (一个引号可以包含很多图像。)当我要删除图像时,我一直在使用quote.removeFromImage(image)
,即使它不再出现在我的应用程序中,我也注意到它仍在我的持久性存储中。我相信如果我使用delete它将永远消失,但是也许我使用了removeFrom错误吗?
func deleteImage(imageIndex: Int) {
let quote = currentQuote //currentQuote was fetched with the context
let image = currentImageArray[imageIndex]
quote?.removeFromImages(image)
coreData.saveContext()
}