Could someone show me some code that puts all the songs names in the user's music library into an array? Then show me how to change song names to artists, albums etc.
1 Answer
Basically this:
id iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
NSArray *allTrackNames = [iTunes valueForKeyPath:@"[email protected][email protected]"];
It will also include things that you might not consider "music" such as podcasts, so you'll probably want to adapt it a bit, but this is basically how you do it.
2 Comments
user377419
can i just copy that into a method or is anything else required?
Chuck
Aside from linking the Scripting Bridge framework and importing the headers, it should work as written. That's the entirety of the actual code needed.