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.
Asked
Active
Viewed 335 times
1 Answers
5
Basically this:
id iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
NSArray *allTrackNames = [iTunes valueForKeyPath:@"sources.@distinctUnionOfArrays.playlists.@distinctUnionOfArrays.tracks.name"];
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.

Chuck
- 234,037
- 30
- 302
- 389
-
can i just copy that into a method or is anything else required? – user377419 Jul 10 '10 at 03:48
-
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. – Chuck Jul 10 '10 at 04:03