Skip to content

Instantly share code, notes, and snippets.

@Li-blog
Created August 8, 2016 14:21
Show Gist options
  • Save Li-blog/ede08be14f8b2c6f015bb7004cead853 to your computer and use it in GitHub Desktop.
Save Li-blog/ede08be14f8b2c6f015bb7004cead853 to your computer and use it in GitHub Desktop.
-(void)_preferencesChanged {
CFStringRef appID = CFSTR("com.wangjinli.weekcountpb");
CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (!keyList) {
[self attemptSettingFallbackPrefs];
return;
}
NSDictionary *preferences = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
CFRelease(keyList);
if (!preferences) {
[self attemptSettingFallbackPrefs];
}
_startDateStr = preferences[@"StartDateStr"] ? preferences[@"StartDateStr"] : @"19700101";
_duration = preferences[@"Duration"] ? [(NSNumber*)preferences[@"Duration"] intValue] : 18;
_weekStartDay = preferences[@"WeekStartDay"] ? preferences[@"WeekStartDay"] : @"Monday";
_lockScreenEnabled = preferences[@"LockScreenEnabled"] ? [(NSNumber*)preferences[@"LockScreenEnabled"] boolValue] : YES;
_nCEnabled = preferences[@"NCEnabled"] ? [(NSNumber*)preferences[@"NCEnabled"] boolValue] : YES;
_displayFormat = preferences[@"DisplayFormat"] ? preferences[@"DisplayFormat"] : @"Week \%W";
[self parseDate];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment