Adding a refresh UIBarButtonItem to a UINavigationController loaded from a NIB

It looks like your viewDidLoad method is allocating but not releasing the bar button item. you should do this:

UIBarButtonItem *button = [[UIBarButtonItem alloc]
     initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
     target:self
         action:@selector(refresh:)];
self.navigationItem.rightBarButtonItem = button;
[button release];

You need to do this not in the nav controller, but in the root view controller that's contained within the navigation controller. In other words, put it in "View Controller" not "Observation List View Controller"

Each controller you push onto the nav controller can have it's own self.navigationItem.whatever and this will be displayed by the nav controller when the new controller is pushed onto its stack.


Worked on SWIFT 4.1

navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: 
UIBarButtonSystemItem.refresh, target: self, action: 
#selector(RootViewController.refresh))