2

I did not get this error warning until I updated to the latest version of Xcode?

Incompatible pointer types initializing 'MPNowPlayingInfoCenter' with an expression of type 'NSNotificationCenter’

CODE:

- (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;
}
iOS Dev
  • 4,143
  • 5
  • 30
  • 58

2 Answers2

1

You can silent the warning by casting default center this way:

MPNowPlayingInfoCenter *center = (MPNowPlayingInfoCenter*)[playingInfoCenter defaultCenter];
iOS Dev
  • 4,143
  • 5
  • 30
  • 58
0

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

David Ansermot
  • 6,052
  • 8
  • 47
  • 82