gpt4 book ai didi

swift - 无法使用类型为 '[String : AnyObject]' 的索引下标类型为 'NSAttributedStringKey' 的值

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:00 26 4
gpt4 key购买 nike

我在我的项目中使用以下代码。更新到 swift 4 后出现错误。我该如何解决?

代码:

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 )
}

以下是错误:


Cannot subscript a value of type '[String : AnyObject]' with an index of type 'NSAttributedStringKey'


Cannot convert value of type '[String : AnyObject]' to expected argument type '[NSAttributedStringKey : Any]?'

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com