- (IBAction)saveImage:(id)sender{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSManagedObject *image = [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:context];
images.image = image;
[image setValue:tmpphoto forKey:@"img"];
CGSize size = tmpphoto.size;
CGFloat ratio = 0;
if (size.width > size.height) {
ratio = 90.0 / size.width;
} else {
ratio = 90.0 / size.height;
}
CGRect rect = CGRectMake(0.0, 0.0, ratio * size.width, ratio * size.height);
UIGraphicsBeginImageContext(rect.size);
[tmpphoto drawInRect:rect];
images.imaget = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
我的实体名称是“图像”,属性为 img(transformable),imgcode(string) 我试图用核心数据将此图像保存到我的设备。但我有这个错误,可能是什么问题?先感谢您...
错误:'NSInvalidArgumentException',原因:'无法将模型与名为'Image'的两个不同实体合并'