AttributedMarkdown icon indicating copy to clipboard operation
AttributedMarkdown copied to clipboard

How do I use attributes with Swift

Open osrl opened this issue 10 years ago • 3 comments

let attributes = [H1:[NSFontAttributeName:font],
            H1:[NSForegroundColorAttributeName:color]] 

this doesn't work. "Type NSString does not confrom to protocol 'Hashable' "

osrl avatar Jan 20 '15 19:01 osrl

In case someone has this problem:

let attributes = [
            NSNumber(unsignedInt: H1.value):[NSFontAttributeName:font,
                                             NSForegroundColorAttributeName:color],
            NSNumber(unsignedInt: H2.value):[NSForegroundColorAttributeName:color]]

osrl avatar Jan 21 '15 19:01 osrl

.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 avatar Oct 07 '15 07:10 buscarini

@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

arielelkin avatar Oct 30 '15 12:10 arielelkin