NSToolbarItem unrecognized selector sent to instance

249 Views Asked by At

I have 3 NSToolbarItems and the first one works just fine, the other two, each time I select them throw

[16392:513506] -[NSToolbarItem isEqualToString:]: unrecognized selector sent to instance 0x6080001203c0


2015-05-26 19:59:26.871 MyApp[16392:513506] (
    0   CoreFoundation                      0x00007fff89f9703c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8a40176e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff89f9a0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff89edfe24 ___forwarding___ + 1028
    4   CoreFoundation                      0x00007fff89edf998 _CF_forwarding_prep_0 + 120
    5   AppKit                              0x00007fff9649d74e +[NSToolbar _shouldIgnoreItemIdentifier:] + 35
    6   AppKit                              0x00007fff9649d6f7 removeIgnoredIdentifiers + 89
    7   AppKit                              0x00007fff9675e526 -[NSToolbar selectableItemIdentifiers] + 224
    8   AppKit                              0x00007fff9675e411 -[NSToolbar _isSelectableItemIdentifier:] + 34
    9   AppKit                              0x00007fff9675e385 -[NSToolbar setSelectedItemIdentifier:] + 79
    10  AppKit                              0x00007fff96654f3c -[NSToolbarItemViewer mouseDown:] + 4951
    11  AppKit                              0x00007fff96bc52fc -[NSWindow _reallySendEvent:isDelayedEvent:] + 14125
    12  AppKit                              0x00007fff96554d76 -[NSWindow sendEvent:] + 470
    13  AppKit                              0x00007fff96551312 -[NSApplication sendEvent:] + 2504
    14  AppKit                              0x00007fff9647ac68 -[NSApplication run] + 711
    15  AppKit                              0x00007fff963f7354 NSApplicationMain + 1832
    16  IPLocation                          0x000000010001769d main + 109
    17  libdyld.dylib                       0x00007fff96ffd5c9 start + 1
    18  ???                                 0x0000000000000003 0x0 + 3
)

I tried disconnecting and reconnecting them from the storyboard,but nothing changed. The IBAction doesn't even get called.

My ViewController

1

There are 1 best solutions below

0
On
 func toolbarSelectableItemIdentifiers(toolbar: NSToolbar) -> [AnyObject] {
//    let array = toolbar.items.filter { contains(Identifier.allValues, $0.itemIdentifier ) }//wrong!
return Identifier.allValues
}

The delegate just needed the name of the identifiers, not the selectable items themselves.