2

在更新到最新版本的 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;
}
4

2 回答 2

1

您可以通过以下方式投射默认中心来使警告静音:

MPNowPlayingInfoCenter *center = (MPNowPlayingInfoCenter*)[playingInfoCenter defaultCenter];
于 2014-10-23T09:47:34.223 回答
0

The last version is the 6.1.
Update to the lastest version.

于 2014-10-23T10:14:58.683 回答