[cocos2d-iPhone] cocos2d 2.1 iOS6.0以上的warning
CDAudioManager.m
line 402
/libs/CocosDenshion/CDAudioManager.m:402:11: 'delegate' is deprecated: first deprecated in iOS 6.0
将以下两行
AVAudioSession* session = [AVAudioSession sharedInstance]; session.delegate = self;
换成:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(interruption:)
name: AVAudioSessionInterruptionNotification
object: [AVAudioSession sharedInstance]];
并添加:
- (void) interruption:(NSNotification*)notification { NSDictionary *interuptionDict = notification.userInfo; NSUInteger interuptionType = (NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey]; if (interuptionType == AVAudioSessionInterruptionTypeBegan) [self beginInterruption]; #if __CC_PLATFORM_IOS >= 40000 else if (interuptionType == AVAudioSessionInterruptionTypeEnded) [self endInterruptionWithFlags:(NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionOptionKey]]; #else else if (interuptionType == AVAudioSessionInterruptionTypeEnded) [self endInterruption]; #endif }
参考:
http://www.cocos2d-iphone.org/forums/topic/cdaudiomanager-line-402-delegate-is-deprecated/#post-390211
http://blog.csdn.net/qq515383106/article/details/8478162