1 #import "DetailViewController.h"
2 #import "EditViewController.h"
3 #import "MasterViewController.h"
6 @interface DetailViewController ()
10 @implementation DetailViewController
11 @synthesize text = _text;
12 @synthesize item = _item;
13 @synthesize master = _master;
15 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
17 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
19 // Custom initialization
28 NSString *note = [Storage load:self.item.path];
32 self.text.text = note;
40 [super viewDidUnload];
41 // Release any retained subviews of the main view.
44 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
49 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
50 if ([[segue identifier] isEqualToString:@"editNote"]) {
51 EditViewController *edit = (EditViewController*)[[[segue destinationViewController] viewControllers] objectAtIndex:0];
52 edit.detailItem = self.item;
53 edit.delegate = self.master;
58 - (void)setItem:(FileItem *)item {
59 if (self.item == item) return;
63 // On iPhone and call by segue, self.text is nil because view is not loaded yet.
65 NSString *note = [Storage load:item.path];
69 self.text.text = note;