First, we need some buttons to let us perform some actions on the table. Edit your view controller as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setupView]; [self setupFetchedResultsController]; } - (void)setupView { // Create Edit Button UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(editNotes:)]; self.navigationItem.leftBarButtonItem = editButton; // Create Add Button UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNote:)]; self.navigationItem.rightBarButtonItem = addButton; } |
Now we need to setup methods for the two buttons. First, lets wire up the addTestRecord method we created in the last tutorial just to make sure our button works (and to give us some… Read more »