session-ios/Signal/src/environment/PropertyListPreferences.m
Frederic Jacobs b6ef5f0b7f Bloomfilter moves to Cache folder
The bloom filter is not user generated content so Apple is not going to
let us store it into the Documents folder. Moving it to the Cache
folder.
2015-03-12 00:46:31 +01:00

37 lines
1.1 KiB
Objective-C

#import "PropertyListPreferences.h"
#import "Constraints.h"
#import "TSStorageManager.h"
#define SignalDatabaseCollection @"SignalPreferences"
@implementation PropertyListPreferences
-(void) clear {
@synchronized(self) {
NSString *appDomain = NSBundle.mainBundle.bundleIdentifier;
[NSUserDefaults.standardUserDefaults removePersistentDomainForName:appDomain];
}
}
- (id)tryGetValueForKey:(NSString *)key {
require(key != nil);
return [TSStorageManager.sharedManager objectForKey:key inCollection:SignalDatabaseCollection];
}
- (void)setValueForKey:(NSString *)key toValue:(id)value {
require(key != nil);
[TSStorageManager.sharedManager setObject:value forKey:key inCollection:SignalDatabaseCollection];
}
- (id)adjustAndTryGetNewValueForKey:(NSString *)key afterAdjuster:(id (^)(id))adjuster {
require(key != nil);
require(adjuster != nil);
@synchronized(self) {
id oldValue = [self tryGetValueForKey:key];
id newValue = adjuster(oldValue);
[self setValueForKey:key toValue:newValue];
return newValue;
}
}
@end