Created
June 5, 2013 05:16
-
-
Save motoishmz/5711764 to your computer and use it in GitHub Desktop.
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
static NSString * const kPlistName = @"ZeroCameraSettings"; | |
static NSString * const kExtention = @"plist"; | |
/*! | |
plist utils | |
*/ | |
+ (NSMutableDictionary*)getPlist | |
{ | |
NSString* path = [self getPlistPath]; | |
NSString *cachePath = [self getCachePath]; | |
NSFileManager *filemanager = [NSFileManager defaultManager]; | |
if (![filemanager fileExistsAtPath:cachePath]) | |
{ | |
[filemanager copyItemAtPath:path toPath:cachePath error:nil]; | |
} | |
return [NSMutableDictionary dictionaryWithContentsOfFile:cachePath]; | |
} | |
+ (NSString*)getPlistPath | |
{ | |
return [[NSBundle mainBundle] pathForResource:kPlistName ofType:kExtention]; | |
} | |
+ (NSString*)getCachePath; | |
{ | |
return [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, | |
NSUserDomainMask, | |
YES) lastObject] | |
stringByAppendingPathComponent:[kPlistName stringByAppendingString:kExtention]]; | |
} | |
+ (BOOL)isInitialLaunch | |
{ | |
NSDictionary* plist = [self getPlist]; | |
NSLog(@"%@", plist); | |
return [plist[@"isInitialLaunch"] boolValue]; | |
} | |
+ (void)doneInitialLaunch | |
{ | |
/*! | |
see also | |
http://d.hatena.ne.jp/hachinobu/20130117/1358414530 | |
*/ | |
NSMutableDictionary* plist = [self getPlist]; | |
plist[@"isInitialLaunch"] = [NSNumber numberWithBool:NO]; | |
[self save:plist]; | |
} | |
+ (void)save:(NSMutableDictionary*)dictionaly | |
{ | |
[dictionaly writeToFile:[self getCachePath] atomically:NO]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment