0

I implemented a method that adds a toolbar item at index each time the method run.

thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3)

I must wrap this code that inserts the toolbar item with an if/else, else I get this item repeatedly added to the toolbar when ever the method runs.

if ?????? {
    // execute only if the toolbar item with identifier does not already exist.
    thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3)
}

I can not find an appropriate way to check the identifier of the current toolbar item at index 3..?

Gary Simpson
  • 2,677
  • 2
  • 17
  • 18

1 Answers1

0

.itemIdentifier as opposed to .identifier

if thetoolbar.items[3].itemIdentifier != "safaributton"{
        thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3)
    }
Gary Simpson
  • 2,677
  • 2
  • 17
  • 18