Klik op PhotoViewController.xib in en druk op ⌘ - N. Select Cocoa Touch Klassen - UIViewController subklasse en controleren Met XIB voor slechts gebruikersinterface. Name it EditingViewController
Open EditingViewController.h en typ in:
classRecipes;
interface EditingViewController.
UIViewController {
Recepten * recepten;
UITextField * nameTextField;
UITextField * cookingTimeTextField;
}
property (nonatomic, behouden) Recepten * recepten;
@ eigenschap (nonatomic, behouden) IBOutletUITextField * nameTextField;
property (nonatomic, behouden) IBOutletUITextField * cookingTimeTextField;
end
Open EditingViewController.
h en typ in:
classRecipes;
interface EditingViewController: UIViewController {
Recepten * recepten;
UITextField * nameTextField;
UITextField * cookingTimeTextField;
}
property (nonatomic, behouden) Recepten * recepten;
property (nonatomic, behouden) IBOutletUITextField * nameTextField;
property ( nonatomic, behouden) IBOutletUITextField * cookingTimeTextField;
end
Sla het open EditingViewController.m en typ in:
#import "EditingViewController.h"
< p> #import "Recipes.
h"
implementation EditingViewController
@ synthetiseren recepten, nameTextField, cookingTimeTextField;
- (void) viewDidLoad {
[superviewDidLoad];
self.title = @ "bewerken";
UIBarButtonItem * cancelButton = [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCanceltarget:selfaction:@selector(cancel)];
self.navigationItem.leftBarButtonItem = CancelButton;
[cancelButton vrijlating];
UIBarButtonItem * saveButton = [[UIBarButtonItemalloc] initWithTitle:@"Save"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(save)];
self.
navigationItem.rightBarButtonItem = SaveButton;
[saveButton vrijlating];
nameTextField.text = recipes.recipeName;
cookingTimeTextField.text = recipes.cookingTime;
}
- (void) annuleren {
[self.navigationControllerpopViewControllerAnimated: JA];
}
- (void) sparen {
recipes.recipeName = nameTextField.text;
recipes.cookingTime = cookingTimeTextField.text;
NSError * error = nil;
if (! [recipes.managedObjectContextsave: & error] ) {