How to add multiple UIBarButtonItems on right side of Navigation Bar?

I would like to have more than a single UIBarButtonItem on the right side of my UINavigationBar. How can I achieve this?

An example of what I am trying are shown below - you can notice that the top right has more than one button.

enter image description here


Use this in swift:

override func viewDidLoad() {
  super.viewDidLoad()

  let editImage    = UIImage(named: "plus")!
  let searchImage  = UIImage(named: "search")!

  let editButton   = UIBarButtonItem(image: editImage,  style: .Plain, target: self, action: "didTapEditButton:")
  let searchButton = UIBarButtonItem(image: searchImage,  style: .Plain, target: self, action: "didTapSearchButton:")

  navigationItem.rightBarButtonItems = [editButton, searchButton]
}

Write the action functions like this:

func didTapEditButton(sender: AnyObject){
    ...
}

func didTapSearchButton(sender: AnyObject){
    ...
}

Swift 4 & 5

    override func viewDidLoad() {
        super.viewDidLoad()
        let editImage    = UIImage(named: "edit")!
        let searchImage  = UIImage(named: "search")!

        let editButton   = UIBarButtonItem(image: editImage,  style: .plain, target: self, action: #selector(didTapEditButton(sender:)))
        let searchButton = UIBarButtonItem(image: searchImage,  style: .plain, target: self, action: #selector(didTapSearchButton(sender:)))

        navigationItem.rightBarButtonItems = [editButton, searchButton]
    }

    @objc func didTapEditButton(sender: AnyObject){

    }

    @objc func didTapSearchButton(sender: AnyObject){

    }

-(void)viewDidLoad{

    UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle:@"Button_1" style:UIBarButtonItemStylePlain target:self action:@selector(button_1:)];

    UIBarButtonItem *anotherButton2 = [[UIBarButtonItem alloc] initWithTitle:@"Button_" style:UIBarButtonItemStylePlain target:self action:@selector(button_2:)];

    self.navigationItem.rightBarButtonItems=@[anotherButton1,anotherButton2];
}