私のプロジェクトでは以下のコードを使用しています。速攻4へのアップデート後、私はエラーを受けています。どうすれば修正できますか?'NSAttributedStringKey'タイプのインデックスを持つ '[String:AnyObject]'の値をサブスクリプトできません
コード:
let returnString : NSAttributedString
if styleList.count > 0
{
var attrs = [String:AnyObject]()
attrs[NSAttributedStringKey.font] = codeFont
for style in styleList
{
if let themeStyle = themeDict[style]
{
for (attrName, attrValue) in themeStyle
{
attrs.updateValue(attrValue, forKey: attrName)
}
}
}
returnString = NSAttributedString(string: string, attributes:attrs)
}
ここあるエラー:
型の値を添字できません '[文字列:ANYOBJECT]' 'NSAttributedStringKey'
タイプのインデックスを持ちます
'[String:AnyObject]'の値を期待される引数型 '[NSAttributedStringKey:Any]に変換できませんか?'
属性がタイプ[NSAttributedStringKey:任意]のものでなければならない、ではありません[文字列:AnyObject]。 –
説明を与える: 'NSAttributedString'は思うように' NSString'のサブクラスではありません。 –
@RamyAlZuhouri細かい作業、ありがとう –