Skip to content

Commit 8e1e563

Browse files
committed
Filename for HKDataStore
1 parent 8cc8ba3 commit 8e1e563

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Common/Classes/HKDataStore.h

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ typedef void (^HKDataStoreSaveHandler)( NSManagedObjectContext *context, NSSet *
5151
NSMutableSet *_chandlers;
5252
NSMutableSet *_shandlers;
5353
NSMutableSet *_detached;
54+
NSString *_filename;
5455
HKDataStoreLocation _location;
5556
BOOL _setup;
5657
BOOL _change;
@@ -65,6 +66,8 @@ typedef void (^HKDataStoreSaveHandler)( NSManagedObjectContext *context, NSSet *
6566

6667
+ (HKDataStore *)defaultStore;
6768

69+
- (void)setFilename:(NSString *)filename;
70+
6871
- (void)addModelBundle:(NSBundle *)bundle;
6972
- (void)setDataStoreLocation:(HKDataStoreLocation)location;
7073
- (void)setUsesLightweightMigration:(BOOL)flag;

Common/Classes/HKDataStore.m

+13-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ - (id)init
8383
{
8484
if ( self = [super init] )
8585
{
86+
[self setFilename:@"Data.db"];
8687
}
8788

8889
return self;
@@ -117,6 +118,17 @@ + (HKDataStore *)defaultStore
117118
return gHKDataStore;
118119
}
119120

121+
- (void)setFilename:(NSString *)filename
122+
{
123+
if ( !_setup )
124+
{
125+
if ( filename != _filename )
126+
{
127+
_filename = [filename copy];
128+
}
129+
}
130+
}
131+
120132
- (void)addModelBundle:(NSBundle *)bundle
121133
{
122134
@synchronized (self)
@@ -470,7 +482,7 @@ - (void)setup
470482
break;
471483
}
472484

473-
url = [NSURL fileURLWithPath:[dir stringByAppendingPathComponent:@"Data.db"]];
485+
url = [NSURL fileURLWithPath:[dir stringByAppendingPathComponent:_filename]];
474486

475487
if ( ![fm fileExistsAtPath:dir isDirectory:NULL] )
476488
{

External/JSONKit

Submodule JSONKit updated 2 files

0 commit comments

Comments
 (0)