// // TextEdit.m // // Created by Michael Heyeck on 10/22/09. // #import "TextEdit.h" @interface TextEdit () - (void)save; - (void)dismiss; @end @implementation TextEdit @synthesize object; @synthesize keyPath; @synthesize textView; /* - (id)initWithStyle:(UITableViewStyle)style { // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. if (self = [super initWithStyle:style]) { } return self; } */ - (void)viewDidLoad { [super viewDidLoad]; // Add buttons self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismiss)] autorelease]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(save)] autorelease]; // Initialize display textView.text = [object valueForKeyPath:keyPath]; // Display KB [textView becomeFirstResponder]; } /* - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } */ /* - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } */ /* - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } */ /* - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } */ /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } - (void)dealloc { [object release]; [keyPath release]; [textView release]; [super dealloc]; } #pragma mark Extension methods - (void)save { [object setValue:textView.text forKeyPath:keyPath]; [self dismiss]; } - (void)dismiss { [self.navigationController popViewControllerAnimated:YES]; } @end