Started a Cocos2D 2.1 template (with no physics engine) in Xcode 4.5, targeted for iOS 6 and iPad. In the CDAudioManager.m file, the following code...
AVAudioSession* session = [AVAudioSession sharedInstance];
session.delegate = self; // Which is what is automatically generated by the template.
...generates the following warning...
"delegate deprecated: first deprecated in iOS 6"
So I go to the apple developer documentation, and it says under "delegate," "Deprecated in iOS 6.0. Use the notifications described in the Notifications section of this class instead."
Problem is, it looks to me like all we're trying to do--forgive my inexperience--is set the delegate for the AVAudioSession to the CDAudioManager instance itself. How do the notifications accomplish this? Or am I just wrong about the goal of the above code?
I haven't tested this but according to this post: http://www.cocos2d-iphone.org/forums/topic/cdaudiomanager-line-402-delegate-is-deprecated/#post-390211
I.e. throw different code runtime depending on iOS version.
Now, my app is iOS 6.0+ only anyway so I'll just go with:
And cross my thumbs.
The error you are running into is in this block of code
To silence the warning change those 2 lines to this:
Hope this helps.
I found a poast about this on the Cocos2D-iPhone.org forums. While I don't fully understand it--but I'm working on it--it did seem to take care of the problem, at least temporarily. What he did was write this method in the CDAudioManger.m file:
Then he replaced:
with this:
Here's the link: http://www.cocos2d-iphone.org/forum/topic/49956
If and when I develop a better understand of what this code is doing, I'll be sure to edit this post.
Instead of using delegate use notification for handling as follows