diff --git a/GammaTest/AppDelegate.m b/GammaTest/AppDelegate.m index e5a328b..00e0403 100644 --- a/GammaTest/AppDelegate.m +++ b/GammaTest/AppDelegate.m @@ -51,6 +51,9 @@ - (UIApplicationShortcutItem *)shortcutItemForCurrentState { - (void)updateShortCutItem { UIApplication *application = [UIApplication sharedApplication]; + if (![application respondsToSelector:@selector(shortcutItems)]) { + return; + } UIApplicationShortcutItem *shortcut = [self shortcutItemForCurrentState]; application.shortcutItems = @[shortcut]; } @@ -68,11 +71,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( @"autoEndHour": @7, @"autoEndMinute": @0, }]; - - if ([application respondsToSelector:@selector(shortcutItems)] && - !application.shortcutItems.count) { - [self updateShortCutItem]; - } + + [self updateShortCutItem]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(userDefaultsChanged:) + name:NSUserDefaultsDidChangeNotification + object:nil]; [GammaController autoChangeOrangenessIfNeeded]; @@ -143,4 +148,8 @@ - (void)application:(UIApplication *)application performActionForShortcutItem:(U completionHandler(handledShortCutItem); } +- (void)userDefaultsChanged:(NSNotification *)notification { + [self updateShortCutItem]; +} + @end