cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

An easy way to get a string of a shortcut object? #49

Closed nicroto closed 9 years ago

nicroto commented 9 years ago

First of all, thanks for the awesome lib. I am using it in my app, Pagehop.

I would like to show a shortcut, somewhere else in the UI (in a menu item's text).

Is there a method I should be using to convert the shortcut object saved in the user defaults to a (human-readable) string?

Thanks.

Regards, Nikolay Tsenkov

shpakovski commented 9 years ago

Hi Nikolay, thanks a lot for the feedback! You can use -[MASShortcut description] or generate it yourself:

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@%@", self.modifierFlagsString, self.keyCodeString];
}

Hope this helps.

nicroto commented 9 years ago

Perfect!

Thanks!