NSManagedObjectContext(ETCoreData) Category Reference
| Declared in | ETCoreData.h | 
Overview
NSManagedObjectContext (ETCoreData) is a helper category that provides easier and better helper methods to manage NSManagedObjectContext objects.
Instance Methods
allObjectsOfType:
Returns all the NSManagedObject objects whose entity name matches the one provided.
- (NSArray *)allObjectsOfType:(NSString *)entityNameParameters
- entityName
 The name of the
NSManagedObjectentities to be queried.
Return Value
A NSArray containing all the NSManagedObject on the local database.
Declared In
ETCoreData.hcountObjectsOfType:withPredicate:
Executes the query with the provided NSPredicate for the NSManagedObject whose entity name matches the NSString entity name provided.
- (int)countObjectsOfType:(NSString *)entityName withPredicate:(NSPredicate *)predicateParameters
- entityName
 The entity name of the
NSManagedObjectentities to be queried.
- predicate
 The
NSPredicatethat will be used to filter the query.
Return Value
The count of NSManagedObject whose entity name matches entityName and fulfills the provided predicate.
Discussion
Internally calls fetchObjectsOfType:withPredicate:andSortDescriptors: in order to fulfill the initial query.
Declared In
ETCoreData.hdeleteObjects:
Iterates throught the list of NSManagedObject provided and calls deleteObject: for each one. Then calls submitChanges;
- (void)deleteObjects:(NSArray *)objectsParameters
- objects
 A
NSArrayofNSManageObjectthat will be iterated to call-deleteObject:on it.
See Also
Declared In
ETCoreData.hdeleteObjectsOfType:withPredicate:
Calls fetchObjectsOfType:withPredicate:andSortDescriptors: with the provided entity name and NSPredicate; then calls deleteObjects: with the resulting NSArray.
- (void)deleteObjectsOfType:(NSString *)entityName withPredicate:(NSPredicate *)predicateParameters
- entityName
 The entity name of the
NSManagedObjectentity
- predicate
 The
NSPredicatethat will be used to filter the query.
Declared In
ETCoreData.hfetchObjectsOfType:withPredicate:andSortDescriptors:
Executes the provided NSPredicate on the NSManagedObject whose entity name matches the one provided sorted by the provided NSArray of NSSortDescriptor.
- (NSArray *)fetchObjectsOfType:(NSString *)entityName withPredicate:(NSPredicate *)predicate andSortDescriptors:(NSArray *)sortDescriptorsParameters
- entityName
 The name of the
NSManagedObjectentities to be queried.
- predicate
 The
NSPredicatethat will be used to filter the query.
- sortDescriptors
 A
NSArraycontainingNSSortDescriptorobjects that will be used to query the database.
Return Value
A NSArray of NSManagedObject that matches the provided predicate.
Declared In
ETCoreData.hfetchSingleObject:withPredicate:
Fetches a single object for the NSManagedObject whose entity name matches the one provided and fulfills the provided NSPredicate.
- (id)fetchSingleObject:(NSString *)entity withPredicate:(NSPredicate *)predicateParameters
- entity
 The name of the
NSManagedObjectentities to be queried.
- predicate
 The
NSPredicatethat will be used to filter the query.
Return Value
The first NSManagedObject that matches the provided predicate on a NSManagedObject whose entity name matches the one provided.
Declared In
ETCoreData.hhasEntityWithId:idColumn:identifier:
Checks if there’s a NSManagedObject in the database whose idColumn matches the provided NSString identifier.
- (BOOL)hasEntityWithId:(NSString *)entityName idColumn:(NSString *)idColumn identifier:(NSString *)identifierParameters
- entityName
 The name of the
NSManagedObjectentities to be queried.
- idColumn
 The name of the column to be used to query looking for the provided identifier.
- identifier
 The
NSStringobject that will be used as the key for searching anNSManagedObject.
Return Value
YES if there’s a NSManagedObject that contains the provided identifier on the selected idColumn, NO otherwise.
Declared In
ETCoreData.hscalarExpressionValueForColumn:expression:entity:withPredicate:
Executes the NSExpression associated to the provided kPredefinedExpression enum value to the column provided on the NSManagedObject whose entity name matches the one provided that also fulfills the NSPredicate provided.
- (int)scalarExpressionValueForColumn:(NSString *)column expression:(kPredefinedExpression)predefinedExpression entity:(NSString *)entity withPredicate:(NSPredicate *)predicateParameters
- column
 The name of the column to be used as the field to execute the
NSExpression.
- predefinedExpression
 The
kPredefiendExpressionenum value to be used when building theNExpression,
- entity
 The name of the
NSManagedObjectentities to be queried.
- predicate
 The
NSPredicatethat will be used to filter the query.
Return Value
The int resulting of executing the NSExpression to the to the column provided on the NSManagedObject with the provided entity name that satisfies the provided NSPredicate.
Discussion
This method internally calls fetchObjectsOfType:withPredicate:andSortDescriptors: to fulfill the provided filtering details.
Declared In
ETCoreData.h