0

i'm currently writing an application in Objective-C which displays the artist name of the song currently being played in iTunes, however i want the artist name to update when the song changes.

This is the method i have so far which gets the artist name and sets a NSTextField to display the artist name.

 - (void)updateArtistName {
iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
     NSString *artistNameString = [NSString stringWithFormat:@"%@", [[iTunes currentTrack] artist]];
     [artistName setStringValue:artistNameString];}

Any help would be much appreciated, thanks, Sami.

Sami
  • 1,374
  • 1
  • 16
  • 43

1 Answers1

3

What you're looking for is: NSDistributedNotificationCenter. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Articles/Registering.html

To figure out which notifications Itunes is sending most people suggest using: https://github.com/kballard/NotificationWatcher

Logan Bailey
  • 7,039
  • 7
  • 36
  • 44