在更新到最新版本的 Xcode 之前,我没有收到此错误警告?
Incompatible pointer types initializing 'MPNowPlayingInfoCenter' with an expression of type 'NSNotificationCenter’
代码:
- (void)doUpdateNowPlayingCenter
{
if (!self.updateNowPlayingCenter || !self.nowPlayingItem)
{
return;
}
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (!playingInfoCenter)
{
return;
}
MPNowPlayingInfoCenter *center = [playingInfoCenter defaultCenter];
NSDictionary *songInfo = @
{
MPMediaItemPropertyTitle: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyTitle],
MPMediaItemPropertyPlaybackDuration: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyPlaybackDuration]
};
center.nowPlayingInfo = songInfo;
}