Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert the change to use `MR_newContext…` etc, to just be `MR_context…

……` as per Apple's guidelines around factory methods
  • Loading branch information...
commit 010abcd19691480d77402b69a22a1a64fe08e1a1 1 parent f4d01b4
@tonyarnold tonyarnold authored
View
14 MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.h
@@ -42,7 +42,7 @@
Creates and returns a new managed object context of type `NSPrivateQueueConcurrencyType`, with it's parent context set to the root saving context.
@return Private context with the parent set to the root saving context
*/
-+ (NSManagedObjectContext *) MR_newContext NS_RETURNS_RETAINED;
++ (NSManagedObjectContext *) MR_context;
/**
Creates and returns a new managed object context of type `NSPrivateQueueConcurrencyType`, with it's parent context set to the root saving context.
@@ -51,7 +51,7 @@
@return Private context with the parent set to the provided context
*/
-+ (NSManagedObjectContext *) MR_newContextWithParent:(NSManagedObjectContext *)parentContext NS_RETURNS_RETAINED;
++ (NSManagedObjectContext *) MR_contextWithParent:(NSManagedObjectContext *)parentContext;
/**
Creates and returns a new managed object context of type `NSPrivateQueueConcurrencyType`, with it's persistent store coordinator set to the provided coordinator.
@@ -60,7 +60,7 @@
@return Private context with it's persistent store coordinator set to the provided coordinator
*/
-+ (NSManagedObjectContext *) MR_newContextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator NS_RETURNS_RETAINED;
++ (NSManagedObjectContext *) MR_contextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator;
/**
Initializes a context of type `NSMainQueueConcurrencyType`.
@@ -117,9 +117,11 @@
#pragma mark - Deprecated Methods — DO NOT USE
@interface NSManagedObjectContext (MagicalRecordDeprecated)
-+ (NSManagedObjectContext *) MR_context MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_newContext instead");
+ (NSManagedObjectContext *) MR_contextWithoutParent MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_newPrivateQueueContext instead");
-+ (NSManagedObjectContext *) MR_contextWithParent:(NSManagedObjectContext *)parentContext MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_newContextWithParent: instead");
-+ (NSManagedObjectContext *) MR_contextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_newContextWithStoreCoordinator: instead");
+
++ (NSManagedObjectContext *) MR_newContext MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_context instead");
++ (NSManagedObjectContext *) MR_newContextWithParent:(NSManagedObjectContext *)parentContext MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_contextWithParent: instead");
++ (NSManagedObjectContext *) MR_newContextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0_USE("Please use +MR_contextWithStoreCoordinator: instead");
+
@end
View
26 MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.m
@@ -25,7 +25,7 @@ + (void) MR_initializeDefaultContextWithCoordinator:(NSPersistentStoreCoordinato
NSAssert(coordinator, @"Provided coordinator cannot be nil!");
if (MagicalRecordDefaultContext == nil)
{
- NSManagedObjectContext *rootContext = [self MR_newContextWithStoreCoordinator:coordinator];
+ NSManagedObjectContext *rootContext = [self MR_contextWithStoreCoordinator:coordinator];
[self MR_setRootSavingContext:rootContext];
NSManagedObjectContext *defaultContext = [self MR_newMainQueueContext];
@@ -52,12 +52,12 @@ + (NSManagedObjectContext *) MR_rootSavingContext;
#pragma mark - Context Creation
-+ (NSManagedObjectContext *) MR_newContext
++ (NSManagedObjectContext *) MR_context
{
- return [self MR_newContextWithParent:[self MR_rootSavingContext]];
+ return [self MR_contextWithParent:[self MR_rootSavingContext]];
}
-+ (NSManagedObjectContext *) MR_newContextWithParent:(NSManagedObjectContext *)parentContext
++ (NSManagedObjectContext *) MR_contextWithParent:(NSManagedObjectContext *)parentContext
{
NSManagedObjectContext *context = [self MR_newPrivateQueueContext];
[context setParentContext:parentContext];
@@ -65,7 +65,7 @@ + (NSManagedObjectContext *) MR_newContextWithParent:(NSManagedObjectContext *)p
return context;
}
-+ (NSManagedObjectContext *) MR_newContextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
++ (NSManagedObjectContext *) MR_contextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
{
NSManagedObjectContext *context = nil;
if (coordinator != nil)
@@ -275,24 +275,24 @@ + (void) MR_setRootSavingContext:(NSManagedObjectContext *)context
#pragma mark - Deprecated Methods — DO NOT USE
@implementation NSManagedObjectContext (MagicalRecordDeprecated)
-+ (NSManagedObjectContext *) MR_context
++ (NSManagedObjectContext *) MR_contextWithoutParent
{
- return [self MR_newContext];
+ return [self MR_newPrivateQueueContext];
}
-+ (NSManagedObjectContext *) MR_contextWithoutParent
++ (NSManagedObjectContext *) MR_newContext
{
- return [self MR_newPrivateQueueContext];
+ return [self MR_context];
}
-+ (NSManagedObjectContext *) MR_contextWithParent:(NSManagedObjectContext *)parentContext
++ (NSManagedObjectContext *) MR_newContextWithParent:(NSManagedObjectContext *)parentContext
{
- return [self MR_newContextWithParent:parentContext];
+ return [self MR_contextWithParent:parentContext];
}
-+ (NSManagedObjectContext *) MR_contextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
++ (NSManagedObjectContext *) MR_newContextWithStoreCoordinator:(NSPersistentStoreCoordinator *)coordinator
{
- return [self MR_newContextWithStoreCoordinator:coordinator];
+ return [self MR_contextWithStoreCoordinator:coordinator];
}
@end
View
4 MagicalRecord/Core/MagicalRecord+Actions.m
@@ -21,7 +21,7 @@ + (void) saveWithBlock:(void(^)(NSManagedObjectContext *localContext))block;
+ (void) saveWithBlock:(void(^)(NSManagedObjectContext *localContext))block completion:(MRSaveCompletionHandler)completion;
{
NSManagedObjectContext *savingContext = [NSManagedObjectContext MR_rootSavingContext];
- NSManagedObjectContext *localContext = [NSManagedObjectContext MR_newContextWithParent:savingContext];
+ NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextWithParent:savingContext];
[localContext MR_setWorkingName:NSStringFromSelector(_cmd)];
@@ -55,7 +55,7 @@ + (void) saveUsingCurrentThreadContextWithBlock:(void (^)(NSManagedObjectContext
+ (void) saveWithBlockAndWait:(void(^)(NSManagedObjectContext *localContext))block;
{
NSManagedObjectContext *savingContext = [NSManagedObjectContext MR_rootSavingContext];
- NSManagedObjectContext *localContext = [NSManagedObjectContext MR_newContextWithParent:savingContext];
+ NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextWithParent:savingContext];
[localContext MR_setWorkingName:NSStringFromSelector(_cmd)];
View
8 Tests/Core/NSManagedObjectContext+MagicalSavesTests.m
@@ -15,7 +15,7 @@ @implementation NSManagedObjectContextMagicalSavesTests
- (void)testSaveToSelfOnlyWhenSaveIsSynchronous
{
NSManagedObjectContext *parentContext = [NSManagedObjectContext MR_defaultContext];
- NSManagedObjectContext *childContext = [NSManagedObjectContext MR_newContextWithParent:parentContext];
+ NSManagedObjectContext *childContext = [NSManagedObjectContext MR_contextWithParent:parentContext];
SingleEntityWithNoRelationships *insertedObject = [SingleEntityWithNoRelationships MR_createEntityInContext:childContext];
@@ -51,7 +51,7 @@ - (void)testSaveToSelfOnlyWhenSaveIsSynchronous
- (void)testSaveToSelfOnlyWhenSaveIsAsynchronous
{
NSManagedObjectContext *parentContext = [NSManagedObjectContext MR_defaultContext];
- NSManagedObjectContext *childContext = [NSManagedObjectContext MR_newContextWithParent:parentContext];
+ NSManagedObjectContext *childContext = [NSManagedObjectContext MR_contextWithParent:parentContext];
SingleEntityWithNoRelationships *insertedObject = [SingleEntityWithNoRelationships MR_createEntityInContext:childContext];
@@ -112,7 +112,7 @@ - (void)testSaveToSelfOnlyWhenSaveIsAsynchronousCallsMainThreadOnCompletion
- (void)testSaveToPersistentStoreWhenSaveIsSynchronous
{
NSManagedObjectContext *parentContext = [NSManagedObjectContext MR_defaultContext];
- NSManagedObjectContext *childContext = [NSManagedObjectContext MR_newContextWithParent:parentContext];
+ NSManagedObjectContext *childContext = [NSManagedObjectContext MR_contextWithParent:parentContext];
SingleEntityWithNoRelationships *insertedObject = [SingleEntityWithNoRelationships MR_createEntityInContext:childContext];
@@ -150,7 +150,7 @@ - (void)testSaveToPersistentStoreWhenSaveIsSynchronous
- (void)testSaveToPersistentStoreWhenSaveIsAsynchronous
{
NSManagedObjectContext *parentContext = [NSManagedObjectContext MR_defaultContext];
- NSManagedObjectContext *childContext = [NSManagedObjectContext MR_newContextWithParent:parentContext];
+ NSManagedObjectContext *childContext = [NSManagedObjectContext MR_contextWithParent:parentContext];
SingleEntityWithNoRelationships *insertedObject = [SingleEntityWithNoRelationships MR_createEntityInContext:childContext];
View
2  Tests/Core/NSManagedObjectContextHelperTests.m
@@ -26,7 +26,7 @@ - (void) testCanCreateContextForCurrentThead
- (void) testCanNotifyDefaultContextOnSave
{
- NSManagedObjectContext *testContext = [NSManagedObjectContext MR_newContextWithParent:[NSManagedObjectContext MR_defaultContext]];
+ NSManagedObjectContext *testContext = [NSManagedObjectContext MR_contextWithParent:[NSManagedObjectContext MR_defaultContext]];
XCTAssertEqualObjects([testContext parentContext], [NSManagedObjectContext MR_defaultContext], @"Parent context should be the default context");
}
Please sign in to comment.
Something went wrong with that request. Please try again.