Search code examples
iphonexcoderightbarbuttonitem

Check if rightBarButtonItem exists or not


Is there a way to check if the current view already has a right bar button, something like:

if (FOO_CODE.rightBarButtonItem != nil) {
    // don't create one
} else {
    // create one
}

Solution

  • if (self.navigationItem.rightBarButtonItem)
    

    has the same effect, testing equality to nil is redundant