Swift 获取索引处NSToolbarItem的标识符
我实现了一个方法,该方法每次运行时都在索引处添加一个工具栏项Swift 获取索引处NSToolbarItem的标识符,swift,desktop-application,nstoolbaritem,Swift,Desktop Application,Nstoolbaritem,我实现了一个方法,该方法每次运行时都在索引处添加一个工具栏项 thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3) 我必须用if/else包装插入工具栏项的代码,否则每当该方法运行时,我都会将该项重复添加到工具栏中 if ?????? { // execute only if the toolbar item with identifier does not already exist. thet
thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3)
我必须用if/else包装插入工具栏项的代码,否则每当该方法运行时,我都会将该项重复添加到工具栏中
if ?????? {
// execute only if the toolbar item with identifier does not already exist.
thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3)
}
我找不到适当的方法来检查索引3处当前工具栏项的标识符。.itemsidentifier而不是.identifier
if thetoolbar.items[3].itemIdentifier != "safaributton"{
thetoolbar.insertItemWithItemIdentifier("safaributton", atIndex: 3)
}