In objective c, I've been using code like this to update MPNowPlayingInfoCenter:
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:
@{ MPMediaItemPropertyArtist : @"Artist!",
MPMediaItemPropertyTitle : @"Title! }];
But in Swift, it doesn't seem like the function "setNowPlayingInfo" is recognized:
MPNowPlayingInfoCenter.defaultCenter().... // Can't identify 'setNowPlayingInfo()'
Is there anything I'm missing?
In Swift, getters/setters work differently. Since there are no more properties like in ObjC, there are no automatically generated setters/getters for you. You should just access the variable directly.
In your case, use:
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = [MPMediaItemPropertyArtist : "Artist!", MPMediaItemPropertyTitle : "Title!"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With