File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,20 @@ @implementation DBManager
2727-(instancetype )initWithDatabaseFilePath : (NSString *)dbFilePath {
2828 self = [super init ];
2929 if (self) {
30- self.appDirectory = [NSSearchPathForDirectoriesInDomains (NSApplicationSupportDirectory, NSUserDomainMask, YES ) firstObject ];
30+ // Get application support directory.
31+ // Create the directory if it does not already exist.
32+ NSError *error;
33+ NSURL *appDirectoryUrl = [[NSFileManager defaultManager ] URLForDirectory: NSApplicationSupportDirectory
34+ inDomain: NSUserDomainMask
35+ appropriateForURL: nil
36+ create: YES
37+ error: &error];
38+ self.appDirectory = appDirectoryUrl.path ;
39+ if (debug) {
40+ if (error) {
41+ NSLog (@" Get application support directory error: %@ " , error);
42+ }
43+ }
3144
3245 // Keep the database filepath
3346 self.databaseFilePath = dbFilePath;
You can’t perform that action at this time.
0 commit comments