[superviewWillAppear: animación];
[photoButtonsetImage: recipes.recipeThumbnailImage forState: UIControlStateNormal];
}
- (void ) cancelar {
[recipes.managedObjectContextdeleteObject: recetas];
NSError * Error = nil;
si ([recipes.managedObjectContextsave: y error]!) {
//error manija
NSLog (@ "sin resolver error% @,% @", error, [error userInfo]);
exit (-1); //Fallo
}
[selfdismissModalViewControllerAnimated: YES];
}
- (void) {salvar
recipes.
recipeName = textFieldOne.text;
recipes.cookingTime = textFieldTwo.text;
NSError * Error = nil;
si ([recipes.managedObjectContextsave: y error]!) {
//Handle error
NSLog (@ "sin resolver error% @,% @", error, [error userInfo]);
exit (-1); //Fallo
}
[selfdismissModalViewControllerAnimated: YES];
}
- (void) {didReceiveMemoryWarning
[superdidReceiveMemoryWarning] ;
}
- (void) {viewDidUnload
}
marca pragma -
#pragma mark fotos
- (IBAction) photoButtonPressed {
[textFieldOne endEditing: YES];
[textFieldTwo endEditing: YES];
UIImagePickerController * imagePicker = [[UIImagePickerControlleralloc] init ];
imagePicker.
delegate = auto;
[selfpresentModalViewController: imagePicker animada: YES]; [liberación imagePicker];
}
- (void ) imagePickerController: (UIImagePickerController *) didFinishPickingImage selector: (UIImage *) SelectedImage editingInfo: (NSDictionary *) editingInfo {
NSManagedObject * oldImage = recipes.recipeImage;
si (oldImage = nil) {
[recipes.managedObjectContextdeleteObject: oldImage];
}
RecipeImage * image = [NSEntityDescriptioninsertNewObjectForEntityForName:@"RecipeImage"inManagedObjectContext:recipes.
managedObjectContext];
recipes.recipeImage = Imagen;
[imagen setValue: SelectedImage forKey: @ "recipeImage"];
Tamaño CGSize = selectedImage.size;
CGFloat ratio = 0;
< p> si (Tamano.Width> size.height) {
ratio = 128,0 /Tamano.Width;
} else {
ratio = 130,0 /size.height;
}
CGRect rect = CGRectMake (0.0, 0.0, relación * Tamano.Width, relación * size.height);
UIGraphicsBeginImageContext (rect.size);
[SelectedImage drawInRect: rect
6