Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use attributes with Swift #32

Open
osrl opened this issue Jan 20, 2015 · 3 comments
Open

How do I use attributes with Swift #32

osrl opened this issue Jan 20, 2015 · 3 comments

Comments

@osrl
Copy link

osrl commented Jan 20, 2015

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

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

@osrl
Copy link
Author

osrl commented Jan 21, 2015

In case someone has this problem:

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

@buscarini
Copy link

.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]]

@arielelkin
Copy link

@buscarini could you please post more of your code? I'm trying to write a complete Swift example. See #38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants