- (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) を持つ「Image」です。このイメージをコア データと共にデバイスに保存しようとしています。しかし、このエラーが発生しました。何が問題なのですか? 前もって感謝します...
エラー: 'NSInvalidArgumentException'、理由: 'Image' という名前の 2 つの異なるエンティティを持つモデルをマージできません''