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:
Saul Mora
2011-11-07 13:28:55 -07:00
parent 83b73554cc
commit 6789935856
2 changed files with 6 additions and 14 deletions

View File

@@ -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>";

View File

@@ -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