aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/MASDictionaryTransformer.m
diff options
context:
space:
mode:
Diffstat (limited to 'Framework/MASDictionaryTransformer.m')
-rw-r--r--Framework/MASDictionaryTransformer.m15
1 files changed, 11 insertions, 4 deletions
diff --git a/Framework/MASDictionaryTransformer.m b/Framework/MASDictionaryTransformer.m
index f0d9b2e..54a7d7a 100644
--- a/Framework/MASDictionaryTransformer.m
+++ b/Framework/MASDictionaryTransformer.m
@@ -11,12 +11,19 @@ static NSString *const MASModifierFlagsKey = @"modifierFlags";
return YES;
}
+// Storing nil values as an empty dictionary lets us differ between
+// “not available, use default value” and “explicitly set to none”.
+// See http://stackoverflow.com/questions/5540760 for details.
- (NSDictionary*) reverseTransformedValue: (MASShortcut*) shortcut
{
- return @{
- MASKeyCodeKey: @([shortcut keyCode]),
- MASModifierFlagsKey: @([shortcut modifierFlags])
- };
+ if (shortcut == nil) {
+ return [NSDictionary dictionary];
+ } else {
+ return @{
+ MASKeyCodeKey: @([shortcut keyCode]),
+ MASModifierFlagsKey: @([shortcut modifierFlags])
+ };
+ }
}
- (MASShortcut*) transformedValue: (NSDictionary*) dictionary