0

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 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.