[英]setDelegate deprecated in iOS 6
I am trying to get this sample code running with iOS 7.0 but I am running into some warnings because of deprecated code. 我试图让这个示例代码与iOS 7.0一起运行,但由于代码已被弃用,我遇到了一些警告。 The sample code provided here hasn't been updated in 3 years.
此处提供的示例代码未在3年内更新。 Here is the solution I found which does make sense to me but I am having trouble implementing in the sample code so it will run inside the iOS simulator.
这是我发现的解决方案,它对我有意义,但我在示例代码中实现时遇到问题,因此它将在iOS模拟器中运行。
AVAudioSession* session = [AVAudioSession sharedInstance];
session.delegate = self;// <-------- DEPRECATED IN IOS 6.0
To silence the warning change those 2 lines to this: 要使警告静音,请更改以下两行:
[[AVAudioSession sharedInstance] setActive:YES error:nil];
Someone else suggested 其他人建议
[AVAudioSession sharedInstance];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:nil];
The above solution is a quick fix but I want to get the program running correctly 上面的解决方案是快速修复,但我想让程序正常运行
But all this makes me wonder how do I say function call setPreferredHardwareSampleRate
into something that is not deprecated 但所有这些让我想知道如何将函数调用
setPreferredHardwareSampleRate
变成不被弃用的东西
[mySession setPreferredHardwareSampleRate: graphSampleRate
error: &audioSessionError];
Generally, when a method is deprecated, the headers/documentation are updated with suggestions about what to do instead. 通常,在不推荐使用某个方法时,会更新标题/文档,并提供有关如何执行操作的建议。 Looks like the documentation in this case suggests
-setPreferredSampleRate:error:
as an alternative. 看起来本案例中的文档建议使用
-setPreferredSampleRate:error:
作为替代方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.