I'm writing a Mac app to update some metadata in my iTunes library using the iTunes scripting bridge but I'm struggling when I try to write changes to the data.
I've created a simple test app in Objective C to demonstrate the issue by just overwriting the comment field of the current track with some static text.
My code is:
iTunesApplication *myiTunesApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
myiTunesApp.currentTrack.comment = @"Overwriting track comment";
BOOL success = myiTunesApp.currentTrack.commitEditing;
This does successfully write the new comment but throws the following exception:
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
)
Could anyone suggest what I might be doing wrong here?
Kind regards :)