- (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();
}
My entity name is “Image” with attributes img(transformable), imgcode(string) im trying to save this image to my device with core data.But i have this error,what can be the problem? Thank you in advance…
Error: ‘NSInvalidArgumentException’, reason: ‘Can’t merge models with two different entities named ‘Image”
With this i have solved my problem.Thanks for everyone.