mirror of
https://github.com/zhigang1992/MagicalRecord.git
synced 2026-01-12 17:32:18 +08:00
There has been much confusion as to where to put a persistent store. This should be the final change for proper support (unless apple modifies the guidelines).
For more information, see the official Apple Docs: http://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW4
This commit is contained in:
@@ -382,13 +382,13 @@
|
||||
C721C7A013D0A3750097AB6F = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C7C9A37013F43D3E002C5B0C /* Third Party */,
|
||||
C721C85513D0C7030097AB6F /* Source */,
|
||||
C77E5FA513D0CBA600298F87 /* Unit Tests */,
|
||||
C721C7E413D0C3A00097AB6F /* Mac App Unit Tests */,
|
||||
C721C80213D0C3CD0097AB6F /* iOS App Unit Tests */,
|
||||
C7C9A37013F43D3E002C5B0C /* Third Party */,
|
||||
C721C7B313D0A3AF0097AB6F /* Frameworks */,
|
||||
C721C7B113D0A3AF0097AB6F /* Products */,
|
||||
C77E5FA513D0CBA600298F87 /* Unit Tests */,
|
||||
C721C85513D0C7030097AB6F /* Source */,
|
||||
C76AF7F813DBE8D300CE2E05 /* README.md */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
|
||||
@@ -36,23 +36,15 @@ static NSPersistentStore *defaultPersistentStore_ = nil;
|
||||
return [self MR_directory:NSDocumentDirectory];
|
||||
}
|
||||
|
||||
+ (NSString *)MR_applicationLibraryDirectory
|
||||
+ (NSString *)MR_applicationStorageDirectory
|
||||
{
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
|
||||
NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString *)kCFBundleNameKey];
|
||||
return [[self MR_directory:NSApplicationSupportDirectory] stringByAppendingPathComponent:applicationName];
|
||||
|
||||
#else
|
||||
|
||||
return [self MR_directory:NSLibraryDirectory];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (NSURL *) MR_urlForStoreName:(NSString *)storeFileName
|
||||
{
|
||||
NSArray *paths = [NSArray arrayWithObjects:[self MR_applicationDocumentsDirectory], [self MR_applicationLibraryDirectory], nil];
|
||||
NSArray *paths = [NSArray arrayWithObjects:[self MR_applicationDocumentsDirectory], [self MR_applicationStorageDirectory], nil];
|
||||
NSFileManager *fm = [[[NSFileManager alloc] init] autorelease];
|
||||
|
||||
for (NSString *path in paths)
|
||||
@@ -65,7 +57,7 @@ static NSPersistentStore *defaultPersistentStore_ = nil;
|
||||
}
|
||||
|
||||
//set default url
|
||||
return [NSURL fileURLWithPath:[[self MR_applicationLibraryDirectory] stringByAppendingPathComponent:storeFileName]];
|
||||
return [NSURL fileURLWithPath:[[self MR_applicationStorageDirectory] stringByAppendingPathComponent:storeFileName]];
|
||||
}
|
||||
|
||||
+ (NSURL *)MR_defaultLocalStoreUrl
|
||||
|
||||
Reference in New Issue
Block a user