#import #include "DCPRootListController.h" @implementation DCPRootListController - (id)readPreferenceValue:(PSSpecifier*)specifier { NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; NSMutableDictionary *settings = [NSMutableDictionary dictionary]; [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"]; } - (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier { NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]]; NSMutableDictionary *settings = [NSMutableDictionary dictionary]; [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]]; [settings setObject:value forKey:specifier.properties[@"key"]]; [settings writeToFile:path atomically:YES]; CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"]; if (notificationName) { CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES); } } - (NSArray *)specifiers { if (!_specifiers) { _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain]; } return _specifiers; } -(void)save { [self.view endEditing:YES]; CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("duplexcalendar.savepressed"), NULL, NULL, YES); } @end