I have the following Objective-C code from webpage https://developer.apple.com/library/ios/documentation/Audio/Conceptual/iPodLibraryAccess_Guide/UsingMediaPlayback/UsingMediaPlayback.html
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter
addObserver: self
selector: @selector (handle_NowPlayingItemChanged:)
name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification
object: musicPlayer];
[notificationCenter
addObserver: self
selector: @selector (handle_PlaybackStateChanged:)
name: MPMusicPlayerControllerPlaybackStateDidChangeNotification
object: musicPlayer];
[musicPlayer beginGeneratingPlaybackNotifications];
I need to translate the code to Swift.
I was able to translate the first line into:
var notificationCenter: NSNotificationCenter = NSNotificationCenter.defaultCenter()
When I translated the second statement, I have the following so far, which Xcode filled in for me:
notificationCenter.addObserver(<#T##observer: AnyObject##AnyObject#>, selector: <#T##Selector#>, name: <#T##String?#>, object: <#T##AnyObject?#>)
I need help with this part.
I believe I should use "self" as the first argument. How do I know what to use as the second argument?
Could someone translate the rest of the code for me?