从 table 中删除 managedObject 但如何删除附加图像?

Deleting a managedObject from table but how to delete attached image?

我现在需要了解如何从托管对象获取图像引用。这是用户滑动并按下删除时的删除部分

            if editingStyle == .Delete {
            // Delete the row 
            //
            let managedObject: NSManagedObject = frc.objectAtIndexPath(indexPath) as! NSManagedObject
//context.deleteObject(managedObject)//outcommented to test
print("moc \(managedObject)")// i can see the right image file id/name but i don't now how to get it<-------
            removeImage("5354B06C-CFCB-4845-BEC3-B4B4855D8A36")//hardcoded to test if removeImage works and it does

            do {
                print("deleted")
                try context.save()
            } catch {
                print(error)
            }

        }

为了让我的代码工作,我只需要从 managedObject 获取图像名称。当我打印("moc (managedObject)")时,我在

中看到图像名称
moc <Appointments: 0x1740c8f10> (entity: Appointments; id: 0xd0000000000c0000 <x-coredata://DE573499-064D-4840-819E-6ED2923E42CC/Appointments/p3> ; data: { appointmentImage = "C374341D-7256-4A67-B836-D82619A64AC8";
appointmentAmount = 258;

我应该怎么做?

不要将对象转换为 NSManagedObject,而是使用您的数据模型。如果 Appointments 是您的约会模式,那么试试这个,

let managedObject = frc.objectAtIndexPath(indexPath) as! Appointments
removeImage(managedObject.appointmentImage)