I am using below code in my project. After update to swift 4 I am getting errors. How can I fix it?
Code:
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 )
}
Here are Errors:
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]?'