Merge pull request #93 from NZKoz/master

Fixes for the MR_* macros when ARC is not enabled.
This commit is contained in:
Magical Panda Software
2011-12-05 18:26:27 -08:00
6 changed files with 19 additions and 25 deletions

View File

@@ -31,10 +31,8 @@ NSString * const kMagicalRecordDidMergeChangesFromiCloudNotification = @"kMagica
+ (void) MR_setDefaultContext:(NSManagedObjectContext *)moc
{
#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
[moc retain];
[defaultManageObjectContext_ release];
#endif
MR_RETAIN(moc);
MR_RELEASE(defaultManageObjectContext_);
defaultManageObjectContext_ = moc;
}
@@ -167,7 +165,7 @@ NSString * const kMagicalRecordDidMergeChangesFromiCloudNotification = @"kMagica
- (void) MR_saveWrapper;
{
#ifdef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
#if MR_USE_ARC
@autoreleasepool
{
[self MR_save];

View File

@@ -25,10 +25,8 @@ static NSManagedObjectModel *defaultManagedObjectModel_ = nil;
+ (void) MR_setDefaultManagedObjectModel:(NSManagedObjectModel *)newDefaultModel
{
#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
[newDefaultModel retain];
[defaultManagedObjectModel_ release];
#endif
MR_RETAIN(newDefaultModel);
MR_RELEASE(defaultManagedObjectModel_);
defaultManagedObjectModel_ = newDefaultModel;
}

View File

@@ -22,10 +22,8 @@ static NSPersistentStore *defaultPersistentStore_ = nil;
+ (void) MR_setDefaultPersistentStore:(NSPersistentStore *) store
{
#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
[store retain];
[defaultPersistentStore_ release];
#endif
MR_RETAIN(store);
MR_RELEASE(defaultPersistentStore_);
defaultPersistentStore_ = store;
}

View File

@@ -29,10 +29,8 @@ NSString * const kMagicalRecordPSCDidCompleteiCloudSetupNotification = @"kMagica
+ (void) MR_setDefaultStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
{
#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
[coordinator retain];
[defaultCoordinator_ release];
#endif
MR_RETAIN(coordinator);
MR_RELEASE(defaultCoordinator_);
defaultCoordinator_ = coordinator;
if (defaultCoordinator_ != nil)

View File

@@ -18,14 +18,18 @@
#import <CoreData/CoreData.h>
#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
#define MR_RETAIN(xx) [xx retain];
#define MR_RELEASE(xx) [xx release];
#define MR_AUTORELEASE(xx) [xx autorelease];
#else
#ifndef MR_USE_ARC
#define MR_USE_ARC 1
#endif
#if MR_USE_ARC
#define MR_RETAIN(xx) ((void)0)
#define MR_RELEASE(xx) ((void)0)
#define MR_AUTORELEASE(xx) ((void)0)
#else
#define MR_RETAIN(xx) [xx retain];
#define MR_RELEASE(xx) [xx release];
#define MR_AUTORELEASE(xx) [xx autorelease];
#endif
#ifdef MR_SHORTHAND

View File

@@ -417,9 +417,7 @@ NSDate * dateFromString(NSString *value, NSString *format)
[formatter setDateFormat:format];
NSDate *parsedDate = [formatter dateFromString:value];
#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
[formatter autorelease];
#endif
MR_AUTORELEASE(formatter);
return parsedDate;
}