你好我理解TTS仅在iOS 7中可用,但我过去使用了很多apis,检查该类是否可用并设法保留以前版本的兼容性,但是使用AVSpeechSynthesizer它似乎不起作用,请你帮我使用适用于iOS 7的TTS并通过在iOS 6中禁用它来保持兼容性,非常感谢.
这是我的代码,但它似乎不起作用
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)) {
if([AVSpeechSynthesizer class]) {
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = AVSpeechUtteranceDefaultSpeechRate/2;
utterance.pitchMultiplier = 0.9;
utterance.preUtteranceDelay = 0;
utterance.postUtteranceDelay = 0;
[synth speakUtterance:utterance];
} else {
// Feature not available, do something else
}
}
Run Code Online (Sandbox Code Playgroud)
我已经在我的项目中链接了avfoundation并设置了部署目标iOS 6,它似乎仅在iOS 7设备上运行时工作,如果它的iOS 6崩溃了.
这是我得到的错误消息
dyld: Symbol not found: _AVSpeechUtteranceDefaultSpeechRate
Run Code Online (Sandbox Code Playgroud) 我试图将自己从objective-c 移动到swift,我有一个名为Market 的自定义类,这个类包含一些属性,
class Market {
var name = String?
var volume = Double?
}
Run Code Online (Sandbox Code Playgroud)
它们中的很多都存储在一个数组中,我试图通过 volume 属性对这个数组进行升序或降序排序。
我试过了,但不起作用,二元运算符“>”不能应用于两个“双?” 操作数
self.market.sort(by:{$0.volume > $1.volume})
Run Code Online (Sandbox Code Playgroud)
最方便的快捷方式是什么?