PSPrefsCore
The lowest level of the three. Use it when you want every key at once, or the path to the file itself.
Include
#import "PSPrefsCore.h"
Functions
Signatures
NSString *PSPrefsPathForDomain(NSString *domain); NSDictionary *PSPrefsCopyDomain(NSString *domain); BOOL PSPrefsSetValue(NSString *domain, NSString *key, id value); BOOL PSPrefsSynchronize(NSString *domain);
| Function | Returns |
|---|---|
PSPrefsPathForDomain |
The plist path for that domain, or nil if the domain name is not usable as a filename. |
PSPrefsCopyDomain |
Every stored key and value, or nil when nothing has been written. |
PSPrefsSetValue |
YES on success. A nil value removes the key. |
PSPrefsSynchronize |
YES when the domain is on disk. |
Example
Objective-C
NSDictionary *all = PSPrefsCopyDomain(@"com.example.mytweak");
for (NSString *key in all) {
NSLog(@"%@ = %@", key, all[key]);
}
Watching for changes
PSPrefsPathForDomain gives you something to watch. A settings
pane writing in another process does not notify you, so a tweak that should
react immediately can watch that path with a DISPATCH_SOURCE_TYPE_VNODE
source rather than polling.