Lauren Quantrell
Lauren Quantrell

Reputation: 2669

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
}

Upvotes: 1

Views: 1082

Answers (2)

Stefan Ticu
Stefan Ticu

Reputation: 2103

if (self.navigationItem.rightBarButtonItem)

has the same effect, testing equality to nil is redundant

Upvotes: 0

Jordan
Jordan

Reputation: 21770

if (self.navigationItem.rightBarButtonItem != nil)
{
   // I exists
} else {
   // I don't exists
}

Upvotes: 3

Related Questions