title: Setting rightBarButtonItem from Navigation Controller
body: <p><strong>How do you set the right bar button from the navigation controller instead of the view controller?</strong></p>
  
  <p>I've been reading about writing SOLID view controller which work only as controllers instead of adding everything to them.</p>
  
  <p>The post suggested to move the navigation logic outside the view controller (which I agree with). Also, the view controller really shouldn't be setting up the navigation controller it's embedded into, so I'm trying to move the code which sets up the navigation bar to my custom UINavigationController class.</p>
  
  <p>I was partly successful, I managed to update the color, but wasn't able to set a <code>rightBarButtonItem</code>.</p>
  
  <p>Adding these lines to the a view controller will work, but I want to do it from the UINavigationController subclass.</p>
  
  <pre><code>let settingsImage = UIImage(named: "settingsButton")
  self.rightBarButton = UIBarButtonItem(image: settingsImage, style: UIBarButtonItemStyle.Plain, target: self, action: "showSettings")
  self.navigationItem.rightBarButtonItem = self.rightBarButton;
  </code></pre>
  
  <p>I've looked at the questions "Default navigation button" which suggest creating a parent view controller and subclassing all view controllers from that, but I really don't like the fact that the view controller is setting up the navigation controller. It should be the other way around.</p>
  
  <p>Edit: I got as far as <code>self.navigationBar.items</code>. If I set that to nil, nothing will be shown. So I probably need to change that. Not yet sure how though.</p>