-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathuserdefaults.m
40 lines (33 loc) · 1.35 KB
/
userdefaults.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
#import <Cocoa/Cocoa.h>
#import "menuet.h"
void setString(const char *key, const char *value) {
NSString *keyStr = [NSString stringWithUTF8String:key];
NSString *valueStr = [NSString stringWithUTF8String:value];
[NSUserDefaults.standardUserDefaults setObject:valueStr forKey:keyStr];
[NSUserDefaults.standardUserDefaults synchronize];
}
const char *getString(const char *key) {
NSString *keyStr = [NSString stringWithUTF8String:key];
NSString *valueStr = [NSUserDefaults.standardUserDefaults stringForKey:keyStr];
return valueStr.UTF8String;
}
void setInteger(const char *key, long value) {
NSString *keyStr = [NSString stringWithUTF8String:key];
[NSUserDefaults.standardUserDefaults setInteger:value forKey:keyStr];
[NSUserDefaults.standardUserDefaults synchronize];
}
long getInteger(const char *key) {
NSString *keyStr = [NSString stringWithUTF8String:key];
NSInteger value = [NSUserDefaults.standardUserDefaults integerForKey:keyStr];
return value;
}
void setBoolean(const char* key, bool value) {
NSString *keyStr = [NSString stringWithUTF8String:key];
[NSUserDefaults.standardUserDefaults setBool:value forKey:keyStr];
[NSUserDefaults.standardUserDefaults synchronize];
}
bool getBoolean(const char *key) {
NSString *keyStr = [NSString stringWithUTF8String:key];
NSInteger value = [NSUserDefaults.standardUserDefaults boolForKey:keyStr];
return value;
}