}
- (void ) cancelar {
[recipes.managedObjectContextdeleteObject: receitas];
NSError * error = nil;
if ([recipes.managedObjectContextsave: & erro]!) {
//erro Handle
NSLog (@ "não resolvidos erro% @,% @", erro, [erro userInfo]);
exit
(1); //Falha
}
[selfdismissModalViewControllerAnimated: YES];
}
- (void) {salvar
recipes.recipeName = textFieldOne.text;
recipes.cookingTime = textFieldTwo.
text;
NSError * error = nil;
if ([recipes.managedObjectContextsave: & erro]!) {
//Handle erro
NSLog (@ "não resolvidos erro% @,% @", erro, [erro userInfo]);
exit
(1); //Falha
}
[selfdismissModalViewControllerAnimated: YES];
}
- (void) {didReceiveMemoryWarning
[superdidReceiveMemoryWarning] ;
}
- (void) {viewDidUnload
}
marca #pragma -
#pragma mark Foto
- (IBAction) photoButtonPressed {
[textFieldOne endEditing: YES];
[textFieldTwo endEditing: YES];
UIImagePickerController * imagePicker = [[UIImagePickerControlleralloc] de init ];
imagePicker.
delegate = auto;
[selfpresentModalViewController: imagePicker animado: YES]; [liberação imagePicker];
}
- (void ) imagePickerController: (UIImagePickerController *) selecionador didFinishPickingImage: (UIImage *) SelectedImage editingInfo: (NSDictionary *) editingInfo {
NSManagedObject * oldimage = recipes.recipeImage;
if (oldimage = nil) {
[recipes.managedObjectContextdeleteObject: oldimage];
}
* RecipeImage imagem = [NSEntityDescriptioninsertNewObjectForEntityForName:@"RecipeImage"inManagedObjectContext:recipes.
managedObjectContext];
recipes.recipeImage = Imagem;
[imagem setValue: SelectedImage forKey: @ "recipeImage"];
CGSize size = selectedImage.size;
CGFloat ratio = 0;
< p> if (size.width> size.height) {
ratio = 128,0 /size.width;
} else {
ratio = 130,0 /size.height;
}
CGRect rect = CGRectMake (0.0, 0.0, razão * size.width, razão * size.height);
UIGraphicsBeginImageContext (rect.size);
[SelectedImage drawInRect: rect];
recipes.
recipeThumbnailImage = UIGraphicsGetImageFromCurrentImageContext ();
[selfdismissModalViewControl