title: How to set action to the backButtonItem on the navigation bar?
body: <p>How to set action to the backButtonItem on the navigation bar? I have a navigation bar, when I'm pressing the back button, I need to alert some message to the user, and only after user's reaction - return to the previous view. How can I do it? Thanx!</p>
  
  <pre><code>- (void)viewDidLoad 
  {
      [super viewDidLoad];
  
      //no one field don't changed yet
      isDirty = FALSE;
  
      //edited user
      //set default values
      newData = [data copy];
  
      //setting navigation controller rigth button
      UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Save"
                                                                  style:UIBarButtonSystemItemDone 
                                                                     target: self 
                                                                     action: @selector(saveBtnUserClick)];
      self.navigationItem.rightBarButtonItem = rightButton; 
      [rightButton release];
  
  
      UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"Back"
                                                                     style:UIBarButtonSystemItemDone 
                                                                    target: self 
                                                                    action: @selector(backBtnUserClick)];
  
      self.navigationItem.backBarButtonItem = leftButton;
      [leftButton release];
  }
  </code></pre>
  
  <p>//and my method for reaction</p>
  
  <pre><code>-(IBAction) backBtnUserClick
  {
      NSLog(@"\n Back pressed");
  
      //back to previous view
      [self.navigationController popViewControllerAnimated: TRUE];
  }
  </code></pre>