-
Notifications
You must be signed in to change notification settings - Fork 41
/
NSUserDefaults+Hack.m
40 lines (33 loc) · 1.18 KB
/
NSUserDefaults+Hack.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
//
// NSUserDefaults+Hack.m
// gitty
//
// Created by brandon on 1/4/11.
// Copyright 2011 redf.net. All rights reserved.
//
#import "NSUserDefaults+Hack.h"
@implementation NSUserDefaults(Hack)
/*- (BOOL)synchronize
{
BOOL result = CFPreferencesAppSynchronize((CFStringRef)[[NSBundle mainBundle] bundleIdentifier]);
if (!result)
{
// there's probably a temp file lingering around... try again.
result = CFPreferencesAppSynchronize((CFStringRef)[[NSBundle mainBundle] bundleIdentifier]);
// regardless of the result, lets clean up any temp files hanging around..
NSString *prefsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences"];
NSDirectoryEnumerator *dirEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:prefsDir];
NSString *match = [[[NSBundle mainBundle] bundleIdentifier] stringByAppendingString:@".plist."];
NSString *file = nil;
while ((file = [dirEnumerator nextObject]))
{
if ([file rangeOfString:match].location != NSNotFound)
{
NSString *fileToRemove = [prefsDir stringByAppendingPathComponent:file];
[[NSFileManager defaultManager] removeItemAtPath:fileToRemove error:nil];
}
}
}
return result;
}*/
@end