Created
February 14, 2013 20:09
-
-
Save romyilano/4955946 to your computer and use it in GitHub Desktop.
NSNotificationCenter example https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Articles/Registering.html#//apple_ref/doc/uid/20000723-CEGCCFID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // here i register a MPMusicPlayerController object to the NSNotificationCenter | |
| MPMusicPlayerController *musicPlayer = | |
| [MPMusicPlayerController applicationMusicPlayer]; | |
| [musicPlayer setQueueWithItemCollection: userMediaItemCollection]; | |
| [musicPlayer beginGeneratingPlaybackNotifications]; | |
| NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; | |
| [notificationCenter | |
| addObserver:self | |
| selector:@selector(handleNowPlayingItemChanged:) | |
| name:@"MPMusicPlayerControllerNowPlayingItemDidChangeNotification" | |
| object:musicPlayer]; | |
| [notificationCenter | |
| addObserver:self | |
| selector:@selector(handlePlaybackStateChanged:) | |
| name:@"MPMusicPlayerCOntrollerPlaybackStateDidChangeNotification" | |
| object:musicPlayer]; | |
| [musicPlayer play]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment