Skip to content

Instantly share code, notes, and snippets.

@motoishmz
Created June 5, 2013 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motoishmz/5711764 to your computer and use it in GitHub Desktop.
Save motoishmz/5711764 to your computer and use it in GitHub Desktop.
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