-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added NSUserDefaults hack to cleanup the junk plist files. :(
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// NSUserDefaults+Hack.h | ||
// gitty | ||
// | ||
// Created by brandon on 1/4/11. | ||
// Copyright 2011 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
@interface NSUserDefaults(Hack) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters