From 7bbaed62276c60c2e83b35b4329f795149be27fc Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Thu, 5 Mar 2015 14:32:51 +0100 Subject: Removed support for dots and spaces in user defaults keys (#64). I could find no way to make the feature work, so I have pulled it from the code. I have also inserted asserts to warn library users who would attempt to use illegal characters in user defaults keys in the future. In short, you want your user defaults keys to be something identifier-like. --- Framework/MASShortcutBinderTests.m | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'Framework/MASShortcutBinderTests.m') diff --git a/Framework/MASShortcutBinderTests.m b/Framework/MASShortcutBinderTests.m index 35542d4..ab8383e 100644 --- a/Framework/MASShortcutBinderTests.m +++ b/Framework/MASShortcutBinderTests.m @@ -95,22 +95,13 @@ static NSString *const SampleDefaultsKey = @"sampleShortcut"; @"Bind shortcut using a default value."); } -// The connection between user defaults and shortcuts is implemented -// using Cocoa Bindings where the dot symbol (“.”) has a special meaning. -// This means we have to escape the dot symbol used in defaults keys, -// otherwise things blow up. Details at . -- (void) testBindingsWithDotSymbol +// See issue #64 for rationale and discussion. +- (void) testIllegalSymbolsInBindingNames { - static NSString *const SampleDefaultsKeyWithDotSymbol = @"sample.Shortcut"; - MASShortcut *shortcut = [MASShortcut shortcutWithKeyCode:1 modifierFlags:1]; - XCTAssertNoThrow([_binder bindShortcutWithDefaultsKey:SampleDefaultsKeyWithDotSymbol toAction:^{}], - @"Binding a shortcut to a defaults key with a dot symbol must not throw."); - [_defaults setObject:[NSKeyedArchiver archivedDataWithRootObject:shortcut] forKey:SampleDefaultsKeyWithDotSymbol]; - XCTAssertTrue([_monitor isShortcutRegistered:shortcut], - @"Read a shortcut value using a defaults key with a dot symbol."); - [_binder breakBindingWithDefaultsKey:SampleDefaultsKeyWithDotSymbol]; - XCTAssertFalse([_monitor isShortcutRegistered:shortcut], - @"Breaking a binding with a dot symbol."); + XCTAssertThrows([_binder bindShortcutWithDefaultsKey:@"foo.bar" toAction:^{}], + @"Throw for illegal binding symbols: a dot (“.”)."); + XCTAssertThrows([_binder bindShortcutWithDefaultsKey:@"foo bar" toAction:^{}], + @"Throw for illegal binding symbols: a space (“ ”)."); } @end -- cgit v1.2.3