作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在苹果的 Working with Cocoa Frameworks它看起来好像 Foundation 和 Swift Foundation 框架通过桥接一起工作。但是,我注意到在尝试使用 NSSpeechSynthesizer 的类方法 availableVoices() 时,它允许我接收到返回的 NSString 数组,但不是字符串。
编译和运行都很好:
let voices = NSSpeechSynthesizer.availableVoices as [NSString]
print(voices)
但是这不会编译:
let voicesTwo = NSSpeechSynthesizer.availableVoices as [String]
如果 the voiceName documentation 为什么这不起作用显示 VoiceName 是一个字符串属性?
我在 VoiceName 文档中看到术语“rawValue”,那么推理是否与某种枚举有关?
最佳答案
看起来 NSSpeechSynthesizer.VoiceName
是一个 Enum
,其 rawValue
为 String
。这与成为字符串不同。
尝试使用
NSSpeechSynthesizer.availableVoices.map { $0.rawValue }
关于swift - 为什么不能将 NSSpeechsynthesier 的类方法 availableVoices 桥接到 Swift 字符串数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50272695/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!