ETCoreDataStore Class Reference
| Inherits from | NSObject | 
| Declared in | ETCoreData.h | 
Overview
Wrapper that manages the NSManagedObjectModel, NSManagedObjectContext & NSPersistentStoreCoordinator for a local database
Tasks
Definition properties
- 
	
		
dataFilePathproperty - 
	
		
managedObjectModelproperty - 
	
		
managedObjectContextproperty - 
	
		
persistentStoreCoordinatorproperty 
Initialization
Manipulation methods
Formatters
Handling
Store manipulation
- 
	
		
– insertObjectFromJson:entityName:dateFormatter: - 
	
		
– insertObjectFromJson:entityName: - 
	
		
– updateObjectFromJson:entityName: - 
	
		
– updateObjectFromJson:entityName:identifierKey:dateFormatter: - 
	
		
– updateObjectFromJson:entityName:predicate:dateFormatter: - 
	
		
– addObjectsFromJsonArray:addSingleSelector: 
Other methods
Properties
dataFilePath
The local path for the NSManagedObjectModel object.
@property (nonatomic, retain) NSString *dataFilePathDeclared In
ETCoreData.hmanagedObjectContext
The NSManagedObjectContext linked to persistentStoreCoordinator.
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContextDeclared In
ETCoreData.hmanagedObjectModel
The NSManagedObjectModel created with the dataFilePath.
@property (nonatomic, retain) NSManagedObjectModel *managedObjectModelDeclared In
ETCoreData.hpersistentStoreCoordinator
The NSPersistentStoreCoordinator that handles the managedObjectModel.
@property (nonatomic, retain) NSPersistentStoreCoordinator *persistentStoreCoordinatorDeclared In
ETCoreData.hInstance Methods
addObjectsFromJsonArray:addSingleSelector:
Adds all the JSON objects from the provided jsonArray via executing addSingleSelector on each one of them.
- (NSSet *)addObjectsFromJsonArray:(id)jsonArray addSingleSelector:(SEL)addSingleSelectorParameters
- jsonArray
 The
JSONarray containing theJSONobjects that will be added to the database.
- addSingleSelector
 The specific
selectorthat will be called with each object as a paramter to be added to the database.
Return Value
A NSSet containing all the NSManagedObject added to the database.
Declared In
ETCoreData.hcancelChanges
Calls the reset method of the managedObjectContext.
- (void)cancelChangesDeclared In
ETCoreData.hclearDatabase
Iterates through the list of NSManagedObject on the local database and calls deleteObjectsOfType:withPredicate on managedObjectContext.
- (void)clearDatabaseDiscussion
// @see NSManagedObjectContext deleteObjectsOfType:withPredicate
// The @see statement was removed because appledoc can’t find the crossreference
Declared In
ETCoreData.hhasFileBeenProcessed:
Checks whether or not the file at provided has been processed.
- (BOOL)hasFileBeenProcessed:(NSString *)fileNameParameters
- fileName
 The name of the file to be checked.
Return Value
YES if the file with name fileName has been processed, NO otherwise.
See Also
Declared In
ETCoreData.hidentifierPredicate:
Generates an NSPredicate with the provided identifier.
- (NSPredicate *)identifierPredicate:(id)identifierParameters
- identifier
 The identifier to be passed on the newly created
NSPredicateobject.
Return Value
A NSPredicate generated by calling [NSPredicate predicateWithFormat:@"identifier = %@", identifier].
Declared In
ETCoreData.hinitWithDataFile:
Initializes the dataFilePath and then creates all the related objects (managedObjectModel, managedObjectContext & persistentStoreCoordinator) based on that.
- (id)initWithDataFile:(NSString *)dataFilePathParameters
- dataFilePath
 The file path pointing to the
NSManagedObjectModel.
Return Value
A fully initialized ETCoreDataStore object.
Declared In
ETCoreData.hinsertObjectFromJson:entityName:
Creates a new NSManagedObject whose name matches the provided entity name; filled with provided JSON dictionary.
- (id)insertObjectFromJson:(id)jsonDictionary entityName:(NSString *)entityNameParameters
- jsonDictionary
 The
JSONdictionary that will be used to populate the newly createdNSManagedObjectentity.
- entityName
 The
NSStringdescribing the entity name of theNSManagedObjectinstance.
Return Value
A newly created NSManagedObject pre-populated with the provided JSON dictionary.
Discussion
This method internally calls insertObjectFromJson:entityName:dateFormatter: with jsonDateFormatter as the NSDateFormatter.
Declared In
ETCoreData.hinsertObjectFromJson:entityName:dateFormatter:
Creates a new NSManagedObject whose name matches the provided entity name; filled with provided JSON dictionary. The provided NSDateFormatter is used to format the NSDate objects found on the jsonDictionary.
- (id)insertObjectFromJson:(id)jsonDictionary entityName:(NSString *)entityName dateFormatter:(NSDateFormatter *)dateFormatterParameters
- jsonDictionary
 The
JSONdictionary that will be used to populate the newly createdNSManagedObjectentity.
- entityName
 The
NSStringdescribing the entity name of theNSManagedObjectinstance.
- dateFormatter
 The
NSDateFormatterthat will be used to format theNSDateobjects found on theJSONdictionary provided.
Return Value
A newly created NSManagedObject pre-populated with the provided JSON dictionary.
Declared In
ETCoreData.hjsonDateFormatter
Returns a caching NSDateFormatter with UTC NSTimeZone and the following format: @"en_US_POSIX"
- (NSDateFormatter *)jsonDateFormatterReturn Value
A NSDateFormatter with UTC NSTimeZone and @"en_US_POSIX" format.
Declared In
ETCoreData.hmarkFileAsProcessed:
Marks the file with name fileName as processed.
- (void)markFileAsProcessed:(NSString *)fileNameParameters
- fileName
 The name of the file to be marked as checked.
See Also
Declared In
ETCoreData.hsubmitChanges
Calls the submitChanges method on managedObjectContext.
- (void)submitChangesDiscussion
// @see NSManagedObjectContext+(ETCoreData) deletedObjectsOfType:withPredicate
// The @see statement was removed because appledoc can’t find the crossreference
Declared In
ETCoreData.hupdateObjectFromJson:entityName:
Updates a NSManageObject instance whose entity name matches the one provided. The properties are set with the provided JSON dictionary and KVO.
- (id)updateObjectFromJson:(id)jsonDictionary entityName:(NSString *)entityNameParameters
- jsonDictionary
 The
JSONdictionary that will be used to update theNSManagedObjectentity retrieved from the database.
- entityName
 The
NSStringdescribing the entity name of theNSManagedObjectinstance.
Return Value
A NSManagedObject instance fetched from the database whose properties are updated with the provided JSON dictionary.
Discussion
This method calls internally updateObjectFromJson:entityName:identifierKey:dateFormatter: with jsonDateFormatter as the NSDateFormatter.
Declared In
ETCoreData.hupdateObjectFromJson:entityName:identifierKey:dateFormatter:
Updates a NSManageObject instance whose entity name matches the one provided. The properties are set with the provided JSON dictionary and KVO.
The provided NSDateFormatter is used to format the NSDate objects found on the jsonDictionary.
- (id)updateObjectFromJson:(id)jsonDictionary entityName:(NSString *)entityName identifierKey:(NSString *)identifierKey dateFormatter:(NSDateFormatter *)dateFormatterParameters
- jsonDictionary
 The
JSONdictionary that will be used to update theNSManagedObjectentity retrieved from the database.
- entityName
 The
NSStringdescribing the entity name of theNSManagedObjectinstance.
- identifierKey
 The name of the unique identifier column/property that will be used to fetch an
NSManagedObjectinstance from the database.
- dateFormatter
 The
NSDateFormatterthat will be used to format theNSDateobjects found on theJSONdictionary provided.
Return Value
A NSManagedObject instance fetched from the database whose properties are updated with the provided JSON dictionary.
Discussion
This method internally calls updateObjectFromJson:entityName:predicate:dateFormatter: in order to fetch the correct entity from the database.
Declared In
ETCoreData.hupdateObjectFromJson:entityName:predicate:dateFormatter:
Updates a NSManagedObject instance whose entity name matches the one provided as well as the predicate provided. The properties are set with the provided JSON dictionary and KVO.
The provided NSDateFormatter is used to format the NSDate objects found on the jsonDictionary.
- (id)updateObjectFromJson:(id)jsonDictionary entityName:(NSString *)entityName predicate:(NSPredicate *)predicate dateFormatter:(NSDateFormatter *)dateFormatterParameters
- jsonDictionary
 The
JSONdictionary that will be used to update theNSManagedObjectentity retrieved from the database.
- entityName
 The
NSStringdescribing the entity name of theNSManagedObjectinstance.
- predicate
 The
NSPredicatethat will be used to fetch and filter the correctNSManagedObjectinstance to be formatted.
- dateFormatter
 The
NSDateFormatterthat will be used to format theNSDateobjects found on theJSONdictionary provided.
Return Value
A NSManagedObject instance fetched from the database whose properties are updated with the provided JSON dictionary.
Declared In
ETCoreData.h