在更新到最新版本的 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/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |