此代码应将我的 uiimage 保存到核心数据。图像存储在它自己的实体中并喜欢另一个实体(关系)
NSEntityDescription *imageEntity = [ NSEntityDescription insertNewObjectForEntityForName:kImage inManagedObjectContext:self.context];
[imageEntity setValue:self.image forKey:kPicture];
[newPerson setValue:imageEntity forKey:kPicture];
NSError *error;
if (![self.context save:&error]) {
NSLog(@"Whoops, couldn't save new associate: %@", [error localizedDescription]);
}
在这里,我尝试将其取回,将其放在自定义单元格上的 uiimageview 中
Person *crt = [self.fetchController objectAtIndexPath:indexPath];
cell.name.text = crt.name;
Image *img = crt.picture;
cell.image.image = img.picture;
这仅在第一次添加图片时有效......重新启动应用程序后,图像不再显示......这是为什么?它被设置为可转换的属性