Skip to content

Commit

Permalink
update folder
Browse files Browse the repository at this point in the history
  • Loading branch information
buidinhnguyen committed Jan 5, 2014
1 parent 4eaca4b commit 1a40567
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions SQLiteManager/SQLiteManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,25 @@ - (id) init {
-(id)initInternal {
self = [super init];
if (self != nil) {
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
self.databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask,YES);
if ([paths count] == 0)
return nil;

BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;

NSString *path = [paths objectAtIndex:0];
NSString *appBundleID = [[NSBundle mainBundle] bundleIdentifier];
NSString *appDataDir = [path stringByAppendingPathComponent:appBundleID];

success = [fileManager createDirectoryAtPath:appDataDir withIntermediateDirectories:YES
attributes:nil error:&error];
if (!success) {
NSAssert1(0, @"Failed to create directory in Application Support with message '%@'.", [error localizedDescription]);
}

self.databasePath = [appDataDir stringByAppendingPathComponent:databaseName];
[self checkAndCreateDatabaseWithOverwrite:NO];
}
return self;
Expand Down

0 comments on commit 1a40567

Please sign in to comment.