在更新到最新版本的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;
}
最佳答案
您可以通过以下方式强制默认中心来使警告静音:
MPNowPlayingInfoCenter *center = (MPNowPlayingInfoCenter*)[playingInfoCenter defaultCenter];
关于ios - Xcode 6.0.1新警告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26220537/