Search code examples
iphonexcodeuinavigationitem

Receiving UINavBar Items actions


- (void)viewDidLoad
{
    //So I created a NavBar Item in my detail view

    UIBarButtonItem * saveButton =
    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
                                                    target:self            
                                                    action:@selector(saveFunc)];
    self.navigationItem.rightBarButtonItem = saveButton;
}

I want to write some code to save the data when the user clicks the save button in the NavBar. How do I write the method for this. I am stuck I did it when I created a navBar item through interface builder but I am having troubles doing it when I create the button through code.


Solution

  • now just implement the method

    -(void) saveFunc

    and dont forget to add:

    [saveButton release];