views:

24

answers:

1

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.

Thanks!

+3  A: 

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.

Chuck
can i just copy that into a method or is anything else required?
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