Cocoa Scripting Bridge to put all song names into an array
Could someone show me some c开发者_如何学编程ode 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.
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.
精彩评论