NSError * error = null;
if ([recipes.managedObjectContextsave: & error]) {Anmeldelser
//Handle feil
NSLog (@ "Uløste feil% @,% @", feil, [error Userinfo]);
exit (-1); //Fail
}
[selfdismissModalViewControllerAnimated: YES];
}
- (void) spare {
recipes.recipeName = textFieldOne.text;
recipes.cookingTime = textFieldTwo.text;
NSError * error = null;
if ([recipes.
managedObjectContextsave: & error]) {
//Handle feil
NSLog (@ "Uløste feil% @,% @", feil, [error Userinfo]);
exit (-1); //Fail
}
[selfdismissModalViewControllerAnimated: YES];
}
- (void) didReceiveMemoryWarning {
[superdidReceiveMemoryWarning] ;
}
- (void) viewDidUnload {
}
#pragma mark -
#pragma mark Photo
- (IBAction) photoButtonPressed {
[textFieldOne endEditing: YES];
[textFieldTwo endEditing: YES];
UIImagePickerController * imagePicker = [[UIImagePickerControlleralloc] init ];
imagePicker.
delegate = selv;
[selfpresentModalViewController: imagePicker animerte: YES] [imagePicker utgivelsen];
}
- (void ) imagePickerController: (UIImagePickerController *) picker didFinishPickingImage: (UIImage *) selectedImage editingInfo: (NSDictionary *) editingInfo {
NSManagedObject * oldImage = recipes.recipeImage;
if (oldImage = null) {
[recipes.managedObjectContextdeleteObject: oldImage];
}
RecipeImage * image = [NSEntityDescriptioninsertNewObjectForEntityForName:@"RecipeImage"inManagedObjectContext:recipes.
managedObjectContext];
recipes.recipeImage = Image;
[image 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, ratio * size.width, ratio * size.height);
UIGraphicsBeginImageContext (rect.size);
[selectedImage drawInRect: rect];
recipes.
recipeThumbnailImage = UIGraphicsGetImageFromCurrentImageContext ();
[selfdismissModalViewControllerAnimated: YES];
}
- (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker {
[selfdismissModalViewControllerAnim
NET - C # - Bruke UserControls Mail …