-
Notifications
You must be signed in to change notification settings - Fork 2
/
HoodPrefsController.m
46 lines (34 loc) · 1.09 KB
/
HoodPrefsController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// HoodPrefsController.m
// Hood
//
// Created by Slava Karpenko on 12/4/08.
// Copyright 2008 Ripdev. All rights reserved.
//
#import "HoodPrefsController.h"
@implementation HoodPrefsController
- (id)specifiers
{
NSMutableArray * specs = [[self loadSpecifiersFromPlistName:@"HoodPrefs" target:self] retain];
return specs;
}
-(void)set:(id)val specifier:(PSSpecifier *)spec
{
CFStringRef key = (CFStringRef)[spec propertyForKey:PSKeyNameKey];
CFStringRef def = (CFStringRef)[spec propertyForKey:PSDefaultsKey];
CFPreferencesSetAppValue(key, val, def);
CFPreferencesAppSynchronize(def);
// broadcast changes
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("com.ripdev.hood.pepyaka"), NULL, NULL, false);
}
-(id)get:(PSSpecifier *)spec
{
CFStringRef key = (CFStringRef)[spec propertyForKey:PSKeyNameKey];
CFStringRef def = (CFStringRef)[spec propertyForKey:PSDefaultsKey];
CFPreferencesAppSynchronize(def);
id val = (id)CFPreferencesCopyAppValue(key, def);
if (val == nil)
val = [spec propertyForKey:PSDefaultValueKey];
return val;
}
@end