*   >> Lectura Educación Artículos >> science >> programación

iPhone Core Data Tutorial Parte 2

(BOOL) animada {

[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

Page   <<  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] >>
Copyright © 2008 - 2016 Lectura Educación Artículos,https://lectura.nmjjxx.com All rights reserved.