From 05f8952c25192e501ec8eb86fee3846b709bf90f Mon Sep 17 00:00:00 2001 From: Saul Mora Date: Sun, 26 Jun 2011 16:41:43 -0600 Subject: [PATCH] Improve support for Mac apps, and more specifically, help prevent rejection from the Mac App Store --- NSPersistentStore+ActiveRecord.m | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/NSPersistentStore+ActiveRecord.m b/NSPersistentStore+ActiveRecord.m index 3df8179..ca37d6c 100644 --- a/NSPersistentStore+ActiveRecord.m +++ b/NSPersistentStore+ActiveRecord.m @@ -19,20 +19,11 @@ static NSPersistentStore *defaultPersistentStore = nil; + (void) setDefaultPersistentStore:(NSPersistentStore *) store { defaultPersistentStore = store; - -//#ifdef UIKIT_EXTERN_CLASS -// if (store == nil) -// { -// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Core Data Error" message:@"The default NSPersistentStore was set to nil. The most likely cause is the NSManagedObjectModel version has changed. Either create a new data store, or delete the previous store to continue" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; -// [alert show]; -// [alert release]; -// } -//#endif } + (NSString *) directory:(int) type -{ - return [NSSearchPathForDirectoriesInDomains(type, NSUserDomainMask, YES) lastObject]; +{ + return [NSSearchPathForDirectoriesInDomains(type, NSUserDomainMask, YES) lastObject]; } + (NSString *)applicationDocumentsDirectory @@ -42,7 +33,18 @@ static NSPersistentStore *defaultPersistentStore = nil; + (NSString *)applicationLibraryDirectory { +#ifdef TARGET_OS_MAC + + NSString *applicationName = [[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString *)kCFBundleNameKey]; + return [[self directory:NSApplicationSupportDirectory] stringByAppendingPathComponent:applicationName]; + +#elif defined(TARGET_OS_IPHONE) + return [self directory:NSLibraryDirectory]; + +#else +#warning Unsupported OS Target specified +#endif } + (NSURL *) urlForStoreName:(NSString *)storeFileName