AttributedMarkdown
AttributedMarkdown copied to clipboard
How do I use attributes with Swift
let attributes = [H1:[NSFontAttributeName:font],
H1:[NSForegroundColorAttributeName:color]]
this doesn't work. "Type NSString does not confrom to protocol 'Hashable' "
In case someone has this problem:
let attributes = [
NSNumber(unsignedInt: H1.value):[NSFontAttributeName:font,
NSForegroundColorAttributeName:color],
NSNumber(unsignedInt: H2.value):[NSForegroundColorAttributeName:color]]
.value didn't work for me, not sure if this has changed in some version of swift. I had to use .rawValue
let attributes = [
NSNumber(unsignedInt: H1.rawValue):[NSFontAttributeName:font,
NSForegroundColorAttributeName:color],
NSNumber(unsignedInt: H2.rawValue):[NSForegroundColorAttributeName:color]]
@buscarini could you please post more of your code? I'm trying to write a complete Swift example. See https://github.com/dreamwieber/AttributedMarkdown/issues/38