gpt4 book ai didi

macos - NSToolbarItem 无法识别的选择器发送到实例

转载 作者:行者123 更新时间:2023-11-28 09:07:26 26 4
gpt4 key购买 nike

我有 3 个 NSToolbarItems,第一个工作正常,另外两个,每次我选择它们时都会抛出

[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
)

我尝试从 Storyboard 中断开并重新连接它们,但没有任何改变。 IBAction 甚至不会被调用。

My ViewController

最佳答案

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

代理只需要标识符的名称,而不是可选项目本身。

关于macos - NSToolbarItem 无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30465749/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com