Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate methods that are internally using MR_contextForCurrentThread. #773

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
//

#import <CoreData/CoreData.h>
#import "MagicalRecordDeprecated.h"

@interface NSManagedObject (MagicalAggregation)

+ (NSNumber *) MR_numberOfEntities;
+ (NSNumber *) MR_numberOfEntities MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSNumber *) MR_numberOfEntitiesWithContext:(NSManagedObjectContext *)context;
+ (NSNumber *) MR_numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm;
+ (NSNumber *) MR_numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSNumber *) MR_numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;

+ (NSUInteger) MR_countOfEntities;
+ (NSUInteger) MR_countOfEntities MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0;
+ (NSUInteger) MR_countOfEntitiesWithContext:(NSManagedObjectContext *)context;
+ (NSUInteger) MR_countOfEntitiesWithPredicate:(NSPredicate *)searchFilter;
+ (NSUInteger) MR_countOfEntitiesWithPredicate:(NSPredicate *)searchFilter MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0;
+ (NSUInteger) MR_countOfEntitiesWithPredicate:(NSPredicate *)searchFilter inContext:(NSManagedObjectContext *)context;

+ (BOOL) MR_hasAtLeastOneEntity;
+ (BOOL) MR_hasAtLeastOneEntity MR_DEPRECATED_WILL_BE_REMOVED_IN_3_0;
+ (BOOL) MR_hasAtLeastOneEntityInContext:(NSManagedObjectContext *)context;

- (id) MR_minValueFor:(NSString *)property;
- (id) MR_maxValueFor:(NSString *)property;
- (id) MR_minValueFor:(NSString *)property MR_INTERNALLY_USING_DEPRECATED_METHODS;
- (id) MR_maxValueFor:(NSString *)property MR_INTERNALLY_USING_DEPRECATED_METHODS;

+ (id) MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context;
+ (id) MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate;
+ (id) MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attributeName withPredicate:(NSPredicate *)predicate MR_INTERNALLY_USING_DEPRECATED_METHODS;

/**
* Supports aggregating values using a key-value collection operator that can be grouped by an attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ + (id) MR_aggregateOperation:(NSString *)function onAttribute:(NSString *)attrib
[ed setExpression:ex];

// determine the type of attribute, required to set the expression return type
NSAttributeDescription *attributeDescription = [[self MR_entityDescription] MR_attributeDescriptionForName:attributeName];
NSAttributeDescription *attributeDescription = [[self MR_entityDescriptionInContext:context] MR_attributeDescriptionForName:attributeName];
[ed setExpressionResultType:[attributeDescription attributeType]];
NSArray *properties = [NSArray arrayWithObject:ed];

Expand Down Expand Up @@ -171,11 +171,11 @@ + (NSArray *) MR_aggregateOperation:(NSString *)collectionOperator onAttribute:(
[expressionDescription setName:@"result"];
[expressionDescription setExpression:expression];

NSAttributeDescription *attributeDescription = [[[self MR_entityDescription] attributesByName] objectForKey:attributeName];
NSAttributeDescription *attributeDescription = [[[self MR_entityDescriptionInContext:context] attributesByName] objectForKey:attributeName];
[expressionDescription setExpressionResultType:[attributeDescription attributeType]];
NSArray *properties = [NSArray arrayWithObjects:groupingKeyPath, expressionDescription, nil];

NSFetchRequest *fetchRequest = [self MR_requestAllWithPredicate:predicate];
NSFetchRequest *fetchRequest = [self MR_requestAllWithPredicate:predicate inContext:context];
[fetchRequest setPropertiesToFetch:properties];
[fetchRequest setResultType:NSDictionaryResultType];
[fetchRequest setPropertiesToGroupBy:[NSArray arrayWithObject:groupingKeyPath]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import <CoreData/CoreData.h>
#import "MagicalRecordDeprecated.h"

extern NSString * const kMagicalRecordImportCustomDateFormatKey;
extern NSString * const kMagicalRecordImportDefaultDateFormatString;
Expand All @@ -21,10 +22,10 @@ extern NSString * const kMagicalRecordImportRelationshipTypeKey;

- (BOOL) MR_importValuesForKeysWithObject:(id)objectData;

+ (instancetype) MR_importFromObject:(id)data;
+ (instancetype) MR_importFromObject:(id)data MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_importFromObject:(id)data inContext:(NSManagedObjectContext *)context;

+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData;
+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData inContext:(NSManagedObjectContext *)context;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ - (BOOL) MR_importValuesForKeysWithObject:(id)objectData

+ (id) MR_importFromObject:(id)objectData inContext:(NSManagedObjectContext *)context;
{
NSAttributeDescription *primaryAttribute = [[self MR_entityDescription] MR_primaryAttributeToRelateBy];
NSAttributeDescription *primaryAttribute = [[self MR_entityDescriptionInContext:context] MR_primaryAttributeToRelateBy];

id value = [objectData MR_valueForAttribute:primaryAttribute];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,57 @@
//

#import <CoreData/CoreData.h>
#import "MagicalRecordDeprecated.h"

@interface NSManagedObject (MagicalFinders)

+ (NSArray *) MR_findAll;
+ (NSArray *) MR_findAll MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_findAllInContext:(NSManagedObjectContext *)context;
+ (NSArray *) MR_findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending;
+ (NSArray *) MR_findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
+ (NSArray *) MR_findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm;
+ (NSArray *) MR_findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_findAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;

+ (NSArray *) MR_findAllWithPredicate:(NSPredicate *)searchTerm;
+ (NSArray *) MR_findAllWithPredicate:(NSPredicate *)searchTerm MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_findAllWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;

+ (instancetype) MR_findFirst;
+ (instancetype) MR_findFirst MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstInContext:(NSManagedObjectContext *)context;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm inContext:(NSManagedObjectContext *)context;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchterm sortedBy:(NSString *)property ascending:(BOOL)ascending;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchterm sortedBy:(NSString *)property ascending:(BOOL)ascending MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchterm sortedBy:(NSString *)property ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm andRetrieveAttributes:(NSArray *)attributes;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm andRetrieveAttributes:(NSArray *)attributes MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm andRetrieveAttributes:(NSArray *)attributes inContext:(NSManagedObjectContext *)context;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortBy ascending:(BOOL)ascending andRetrieveAttributes:(id)attributes, ...;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortBy ascending:(BOOL)ascending andRetrieveAttributes:(id)attributes, ... MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortBy ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context andRetrieveAttributes:(id)attributes, ...;
+ (instancetype) MR_findFirstByAttribute:(NSString *)attribute withValue:(id)searchValue;
+ (instancetype) MR_findFirstByAttribute:(NSString *)attribute withValue:(id)searchValue MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;
+ (instancetype) MR_findFirstOrderedByAttribute:(NSString *)attribute ascending:(BOOL)ascending;
+ (instancetype) MR_findFirstOrderedByAttribute:(NSString *)attribute ascending:(BOOL)ascending MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstOrderedByAttribute:(NSString *)attribute ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;

+ (instancetype) MR_findFirstOrCreateByAttribute:(NSString *)attribute withValue:(id)searchValue;
+ (instancetype) MR_findFirstOrCreateByAttribute:(NSString *)attribute withValue:(id)searchValue MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_findFirstOrCreateByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;

+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue inContext:(NSManagedObjectContext *)context;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_findByAttribute:(NSString *)attribute withValue:(id)searchValue andOrderBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR

+ (NSFetchedResultsController *) MR_fetchController:(NSFetchRequest *)request delegate:(id<NSFetchedResultsControllerDelegate>)delegate useFileCache:(BOOL)useFileCache groupedBy:(NSString *)groupKeyPath inContext:(NSManagedObjectContext *)context;

+ (NSFetchedResultsController *) MR_fetchAllWithDelegate:(id<NSFetchedResultsControllerDelegate>)delegate;
+ (NSFetchedResultsController *) MR_fetchAllWithDelegate:(id<NSFetchedResultsControllerDelegate>)delegate MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSFetchedResultsController *) MR_fetchAllWithDelegate:(id<NSFetchedResultsControllerDelegate>)delegate inContext:(NSManagedObjectContext *)context;

+ (NSFetchedResultsController *) MR_fetchAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm groupBy:(NSString *)groupingKeyPath delegate:(id<NSFetchedResultsControllerDelegate>)delegate;
+ (NSFetchedResultsController *) MR_fetchAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm groupBy:(NSString *)groupingKeyPath delegate:(id<NSFetchedResultsControllerDelegate>)delegate MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSFetchedResultsController *) MR_fetchAllSortedBy:(NSString *)sortTerm ascending:(BOOL)ascending withPredicate:(NSPredicate *)searchTerm groupBy:(NSString *)groupingKeyPath delegate:(id<NSFetchedResultsControllerDelegate>)delegate inContext:(NSManagedObjectContext *)context;

+ (NSFetchedResultsController *) MR_fetchAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending;
+ (NSFetchedResultsController *) MR_fetchAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSFetchedResultsController *) MR_fetchAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending inContext:(NSManagedObjectContext *)context;

+ (NSFetchedResultsController *) MR_fetchAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending delegate:(id<NSFetchedResultsControllerDelegate>)delegate;
+ (NSFetchedResultsController *) MR_fetchAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending delegate:(id<NSFetchedResultsControllerDelegate>)delegate MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSFetchedResultsController *) MR_fetchAllGroupedBy:(NSString *)group withPredicate:(NSPredicate *)searchTerm sortedBy:(NSString *)sortTerm ascending:(BOOL)ascending delegate:(id<NSFetchedResultsControllerDelegate>)delegate inContext:(NSManagedObjectContext *)context;

#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ + (instancetype) MR_findFirstWithPredicate:(NSPredicate *)searchTerm sortedBy:(N
ascending:ascending
withPredicate:searchTerm
inContext:context];
[request setPropertiesToFetch:[self MR_propertiesNamed:attributes]];
[request setPropertiesToFetch:[self MR_propertiesNamed:attributes inContext:context]];

return [self MR_executeFetchRequestAndReturnFirstObject:request inContext:context];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
+ (NSUInteger) MR_defaultBatchSize;
+ (void) MR_setDefaultBatchSize:(NSUInteger)newBatchSize;

+ (NSArray *) MR_executeFetchRequest:(NSFetchRequest *)request;
+ (NSArray *) MR_executeFetchRequest:(NSFetchRequest *)request MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_executeFetchRequest:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context;
+ (instancetype) MR_executeFetchRequestAndReturnFirstObject:(NSFetchRequest *)request;
+ (instancetype) MR_executeFetchRequestAndReturnFirstObject:(NSFetchRequest *)request MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_executeFetchRequestAndReturnFirstObject:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context;

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
Expand All @@ -34,27 +34,28 @@

#endif

+ (NSEntityDescription *) MR_entityDescription;
+ (NSEntityDescription *) MR_entityDescription MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSEntityDescription *) MR_entityDescriptionInContext:(NSManagedObjectContext *)context;
+ (NSArray *) MR_propertiesNamed:(NSArray *)properties;
+ (NSArray *) MR_propertiesNamed:(NSArray *)properties MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (NSArray *) MR_propertiesNamed:(NSArray *)properties inContext:(NSManagedObjectContext*)context;

+ (instancetype) MR_createEntity;
+ (instancetype) MR_createEntity MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (instancetype) MR_createEntityInContext:(NSManagedObjectContext *)context;

- (BOOL) MR_deleteEntity;
- (BOOL) MR_deleteEntity MR_INTERNALLY_USING_DEPRECATED_METHODS;
- (BOOL) MR_deleteEntityInContext:(NSManagedObjectContext *)context;

+ (BOOL) MR_deleteAllMatchingPredicate:(NSPredicate *)predicate;
+ (BOOL) MR_deleteAllMatchingPredicate:(NSPredicate *)predicate MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (BOOL) MR_deleteAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context;

+ (BOOL) MR_truncateAll;
+ (BOOL) MR_truncateAll MR_INTERNALLY_USING_DEPRECATED_METHODS;
+ (BOOL) MR_truncateAllInContext:(NSManagedObjectContext *)context;

+ (NSArray *) MR_ascendingSortDescriptors:(NSArray *)attributesToSortBy;
+ (NSArray *) MR_descendingSortDescriptors:(NSArray *)attributesToSortBy;

- (instancetype) MR_inContext:(NSManagedObjectContext *)otherContext;
- (instancetype) MR_inThreadContext;
- (instancetype) MR_inThreadContext MR_INTERNALLY_USING_DEPRECATED_METHODS;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,37 @@ + (NSEntityDescription *) MR_entityDescription

+ (NSArray *) MR_propertiesNamed:(NSArray *)properties
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSEntityDescription *description = [self MR_entityDescription];
#pragma clang diagnostic pop

NSMutableArray *propertiesWanted = [NSMutableArray array];

if (properties)
{
NSDictionary *propDict = [description propertiesByName];

for (NSString *propertyName in properties)
{
NSPropertyDescription *property = [propDict objectForKey:propertyName];
if (property)
{
[propertiesWanted addObject:property];
}
else
{
MRLogWarn(@"Property '%@' not found in %lx properties for %@", propertyName, (unsigned long)[propDict count], NSStringFromClass(self));
}
}
}
return propertiesWanted;
}

+ (NSArray *) MR_propertiesNamed:(NSArray *)properties inContext:(NSManagedObjectContext *)context
{
NSEntityDescription *description = [self MR_entityDescriptionInContext:context];

NSMutableArray *propertiesWanted = [NSMutableArray array];

if (properties)
Expand Down Expand Up @@ -175,7 +205,10 @@ + (id) MR_createEntityInContext:(NSManagedObjectContext *)context
NSEntityDescription *entity = nil;
if (context == nil)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
entity = [self MR_entityDescription];
#pragma clang diagnostic pop
}
else
{
Expand Down
Loading