我正在编写一个Mac应用程序,使用iTunes脚本桥更新iTunes资料库中的某些元数据,但是当我尝试写入数据更改时,我感到很挣扎。
我已经在Objective C中创建了一个简单的测试应用,通过使用一些静态文本覆盖当前曲目的注释字段来演示该问题。
我的代码是:
iTunesApplication *myiTunesApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
myiTunesApp.currentTrack.comment = @"Overwriting track comment";
BOOL success = myiTunesApp.currentTrack.commitEditing;
此 成功写入新评论,但会抛出以下异常:
2016-11-01 21:46:55.307 iTunesScriptingBridgeExample[11117:1091018] -[ITunesTrack commitEditing]: unrecognized selector sent to instance 0x60800004b040
2016-11-01 21:46:55.308 iTunesScriptingBridgeExample[11117:1091018] -[ITunesTrack commitEditing]: unrecognized selector sent to instance 0x60800004b040
2016-11-01 21:46:55.310 iTunesScriptingBridgeExample[11117:1091018] (
0 CoreFoundation 0x00007fff9a8ca4f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8f6e2f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff9a9341ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff9a83a571 ___forwarding___ + 1009
4 CoreFoundation 0x00007fff9a83a0f8 _CF_forwarding_prep_0 + 120
5 iTunesScriptingBridgeExample 0x00000001000012a5 -[ViewController btnClicked:] + 197
6 libsystem_trace.dylib 0x00007fff89e9c07a _os_activity_initiate + 75
7 AppKit 0x00007fff8a9a2dbd -[NSApplication sendAction:to:from:] + 460
8 AppKit 0x00007fff8a9b4f12 -[NSControl sendAction:to:] + 86
9 AppKit 0x00007fff8a9b4e3c __26-[NSCell _sendActionFrom:]_block_invoke + 131
10 libsystem_trace.dylib 0x00007fff89e9c07a _os_activity_initiate + 75
11 AppKit 0x00007fff8a9b4d99 -[NSCell _sendActionFrom:] + 144
12 libsystem_trace.dylib 0x00007fff89e9c07a _os_activity_initiate + 75
13 AppKit 0x00007fff8a9b33be -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2693
14 AppKit 0x00007fff8a9fbf04 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 744
15 AppKit 0x00007fff8a9b1ae8 -[NSControl mouseDown:] + 669
16 AppKit 0x00007fff8af063c9 -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322
17 AppKit 0x00007fff8af073ad -[NSWindow _reallySendEvent:isDelayedEvent:] + 212
18 AppKit 0x00007fff8a946539 -[NSWindow sendEvent:] + 517
19 AppKit 0x00007fff8a8c6a38 -[NSApplication sendEvent:] + 2540
20 AppKit 0x00007fff8a72ddf2 -[NSApplication run] + 796
21 AppKit 0x00007fff8a6f7368 NSApplicationMain + 1176
22 iTunesScriptingBridgeExample 0x0000000100001322 main + 34
23 libdyld.dylib 0x00007fff8e6595ad start + 1
24 ??? 0x0000000000000003 0x0 + 3
)
有人可以在这里暗示我可能做错了吗?
亲切的问候:)
答案 0 :(得分:0)
ITunesTrack
没有commitEditing
的属性或实现。
commitEditing
是NSEditor
协议的一部分。
NSEditor非正式协议由控制器和用户界面元素实现。它提供了一种请求接收方提交或丢弃任何挂起编辑的方法。
这些方法通常由控制器在用户界面元素上调用。它们也可以发送到控制器,以响应用户尝试保存文档或退出应用程序。
NSController提供此协议的实现,支持绑定的Application Kit用户界面元素也是如此。