//kahva virhe
NSLog (@ "Ratkaisematon virhe% @,% @", virhe, [error UserInfo]);
exit (-1); //Fail
}
[selfdismissModalViewControllerAnimated: KYLLÄ];
}
- (void) säästää {
recipes.recipeName = textFieldOne.text;
recipes.cookingTime = textFieldTwo.text;
NSError * error = nolla;
jos (! [recipes.
managedObjectContextsave: & error]) {
//kahva virhe
NSLog (@ "Ratkaisematon virhe% @,% @", virhe, [error UserInfo]);
exit (-1); //Fail
}
[selfdismissModalViewControllerAnimated: KYLLÄ];
}
- (void) didReceiveMemoryWarning {
[superdidReceiveMemoryWarning] ;
}
- (void) viewDidUnload {
}
# pragma Mark -
# pragma merkki Valokuva
- (IBAction) photoButtonPressed {
[textFieldOne endEditing: YES];
[textFieldTwo endEditing: YES];
UIImagePickerController * imagePicker = [[UIImagePickerControlleralloc] init ];
imagePicker.
delegate = itse;
[selfpresentModalViewController: imagePicker animoitu: YES]; [imagePicker release];
}
- (void ) imagePickerController: (UIImagePickerController *) Picker didFinishPickingImage: (UIImage *) selectedImage editingInfo: (NSDictionary *) editingInfo {
NSManagedObject * oldImage = recipes.recipeImage;
jos (oldImage! = nolla) {
[recipes.managedObjectContextdeleteObject: oldImage];
}
RecipeImage * kuva = [NSEntityDescriptioninsertNewObjectForEntityForName:@"RecipeImage"inManagedObjectContext:recipes.
managedObjectContext];
recipes.recipeImage = Image;
[kuva SetValue: selectedImage forKey: @ "recipeImage"];
CGSize size = selectedImage.size;
CGFloat suhde = 0;
< p> jos (size.width> size.height) {
suhde = 128,0 /size.width;
} else {
suhde = 130,0 /size.height;
}
CGRect rect = CGRectMake (0,0, 0,0, suhde * size.width, suhde * size.height);
UIGraphicsBeginImageContext (rect.size);
[selectedImage drawInRect: RECT];
recipes.
recipeThumbnailImage = UIGraphicsGetImageFromCurrentImageContext ();
[selfdismissModalViewControllerAnimated: KYLLÄ];
}
- (void) imagePickerControllerDidCancel: (UIImagePickerController *) poimija {
[selfdismissModalViewControllerAnimated: KYLLÄ];
}
- (void)
net Käyttäjän Control