嗨,我在向字典附加值时遇到错误。我正在使用Xcode 7
和Swift 2
。
错误消息: 无法将类型的值转换[String: String?]
为预期的参数类型[String: String!]
宣言:
var arrVoiceLanguages: [Dictionary<String, String!>] = []
以下是我的功能
for voice in AVSpeechSynthesisVoice.speechVoices() {
let voiceLanguageCode = (voice as AVSpeechSynthesisVoice).language
let languageName = NSLocale.currentLocale().displayNameForKey(NSLocaleIdentifier, value: voiceLanguageCode)
let dictionary = ["languageName": languageName, "languageCode": voiceLanguageCode]
arrVoiceLanguages.append(dictionary)
}
任何帮助表示赞赏。
我不知道为什么人们对这个问题投反对票。!