CYCoreData Class Reference
| Inherits from | NSObject |
| Declared in | CYCoreData.h CYCoreData.m |
Tasks
Class methods
-
+ liason -
+ reset -
+ readContext -
+ temporaryWriteContext -
+ saveSynchronously -
+ saveAsynchronously -
+ saveContextAndWait:
Properties
-
dataBaseFileproperty -
modelFileproperty -
bundleNameproperty -
isTestproperty -
readContextproperty
Config
-
– initWithSqliteFileName:withModelFileName:inBundleName: -
– initWithSqliteFileName:withModelFileName: -
– createStoreAndManagedObjectModel -
+ configureModelUniqueIdentifier:ofDataType:withJSONSearchString: -
+ configureUniqueIdentifier:
Methods
Properties
bundleName
The name NSString of the bundle that contains the model file
@property (nonatomic, strong) NSString *bundleNameDiscussion
Warning: If nil, CYCoreData is using the main bundle
Declared In
CYCoreData.hdataBaseFile
The name NSString of the database file name that will get saved in the cache directory
@property (nonatomic, strong) NSString *dataBaseFileDeclared In
CYCoreData.hisTest
If set to YES, CYCoreData uses an NSInMemoryStoreType and does not write data to sqlite file via NSSQLiteStoreType.
@property (nonatomic, assign) BOOL isTestDiscussion
@example Unit testing.
Declared In
CYCoreData.hmodelFile
The name NSString of the .xcdatamodeld in the bundle
@property (nonatomic, strong) NSString *modelFileDeclared In
CYCoreData.hreadContext
Returns NSManagedObjectContext of [CYCoreData liason].readContext private property. The concurrencyType is NSMainQueueConcurrencyType which means all fetched entities will be on the main runloop and suitable for view display.
@property (nonatomic, strong) NSManagedObjectContext *readContextReturn Value
NSManagedObjectContext of [CYCoreData liason].readContext
Discussion
Warning: It is not wise to change or save to this context directly. ONLY READ
Declared In
CYCoreData.hClass Methods
configureModelUniqueIdentifier:ofDataType:withJSONSearchString:
Sets the keys for and type of unique indexer for NSManagedObjects. This key is used to fetch unique NSEntity in the database.
+ (void)configureModelUniqueIdentifier:(NSString *)uniquePropertyKey ofDataType:(UniqueObjectValueType)uniqueObjectValueType withJSONSearchString:(NSString *)jsonSearchPropertyKeyParameters
- uniquePropertyKey
NSStringfor the unique property key if the NSManagedObject; example @“uid”
- uniqueObjectValueType
UniqueObjectValueTypetype of value the uniquePropertyKey is
- jsonSearchPropertyKey
NSStringthe key the unique property will have on a JSON of for that object
Discussion
Warning: If called, must call before init.
Declared In
CYCoreData.hconfigureUniqueIdentifier:
Utility method for configureModelUniqueIdentifier:ofDataType:withJSONSearchString:
+ (void)configureUniqueIdentifier:(UniqueIdentiferStruct)uniqueIdentiferStructParameters
- `UniqueIdentiferStruct`
Predefined struct of the values passesd to
configureModelUniqueIdentifier:ofDataType:withJSONSearchString:
Discussion
Warning: If called, must call before init.
Declared In
CYCoreData.hliason
Return singleton instance of CYCoreData
+ (instancetype)liasonReturn Value
Return singleton instance of CYCoreData
Discussion
Warning: Must call configureSqliteFileName:withModelFileName first.
Declared In
CYCoreData.hreadContext
Class method readContext which forwards to the [[CYCoreDataInstance liason] readContext] method
+ (NSManagedObjectContext *)readContextReturn Value
NSManagedObjectContext of [CYCoreDataInstance liason].readContext
Declared In
CYCoreData.hreset
Class method reset which forwards to the [[CYCoreDataInstance liason] reset] *
+ (void)resetDeclared In
CYCoreData.hsaveAsynchronously
Class method saveAsynchronously which forwards to the [[CYCoreDataInstance liason] saveAsynchronously] *
+ (void)saveAsynchronouslyDeclared In
CYCoreData.hsaveContextAndWait:
Class method saveContextAndWait: which forwards to the [[CYCoreDataInstance liason] saveContextAndWait:] method
+ (void)saveContextAndWait:(BOOL)shouldWaitParameters
- shouldWait
BOOLto forward to the [[CYCoreDataInstance liason] saveContextAndWait:] method
Declared In
CYCoreData.hsaveSynchronously
Class method saveSynchronously which forwards to the [[CYCoreDataInstance liason] saveSynchronously] *
+ (void)saveSynchronouslyDeclared In
CYCoreData.htemporaryWriteContext
Class method temporaryWriteContext which forwards to the [[CYCoreDataInstance liason] temporaryWriteContext] method
+ (NSManagedObjectContext *)temporaryWriteContextReturn Value
NSManagedObjectContext of [[CYCoreDataInstance liason] temporaryWriteContext]
Declared In
CYCoreData.hInstance Methods
createStoreAndManagedObjectModel
Creates datebase from the model file
- (void)createStoreAndManagedObjectModelDiscussion
Warning: Must be called to user CYCoredata funcationality
Declared In
CYCoreData.hinitWithSqliteFileName:withModelFileName:
Configures the file name for the .sqlite saved in the NSCachesDirectory. Tells CYCoreData the name of the *.xcdatamodeld to use and assumes it is located in the main bundle
- (id)initWithSqliteFileName:(NSString *)dataBaseFileName withModelFileName:(NSString *)modelFileNameParameters
- dataBaseFileName
NSStringof the database file name that will get saved in the cache directory
- withModelFileName
NSStringof the .xcdatamodeld in the bundle
Declared In
CYCoreData.hinitWithSqliteFileName:withModelFileName:inBundleName:
Configures the file name for the .sqlite saved in the NSCachesDirectory. Tells CYCoreData the name of the *.xcdatamodeld to use and what bundle to search for it in
- (id)initWithSqliteFileName:(NSString *)dataBaseFileName withModelFileName:(NSString *)modelFileName inBundleName:(NSString *)bundleNameParameters
- dataBaseFileName
NSStringof the database file name that will get saved in the cache directory
- bundleName
NSStringof the bundle name that contains the modelfile
- withModelFileName
NSStringof the .xcdatamodeld in the bundle
Discussion
Warning: Do not use if .xcdatamodeld is in the mainbundle.
Declared In
CYCoreData.hreset
Empties database of all entities, destroys NSManagedObject model and NSPersistantStoreCoordinator.
- (void)resetDiscussion
Warning: Does not reset config class variables.
Declared In
CYCoreData.hsaveAsynchronously
Calls a Asychronous(performBlock) action to the top NSManagedObjectContext to write the changes to disk.
- (void)saveAsynchronouslyDiscussion
@example Call when ever sychronous behavior is not desired.
Declared In
CYCoreData.hsaveContextAndWait:
For topLevelContext performBlockAndWait pass YES. For topLevelContext performBlock pass NO.
- (void)saveContextAndWait:(BOOL)andWaitParameters
- andWait
BOOLfor identify call to topLevelContextperformBlockorperformBlockAndWait
Declared In
CYCoreData.hsaveSynchronously
Calls a sychronous(performBlockAndWait) action to the top NSManagedObjectContext to write the changes to disk.
- (void)saveSynchronouslyDiscussion
@example Call when app terminates or goes in to background.
Declared In
CYCoreData.htemporaryWriteContext
Returns a brand NSManagedObjectContext of spawned off of the [CYCoreData readContext]. To update the database, fetch the NSEntityDescriptions from this context, create or modify as you see fit. When finished, immediately call either [temporaryWriteContext saveSynchronously] or [temporaryWriteContext saveAsynchronously]. This ensures that the changes will be pushed up to the [CYCoreData readContext], then written to disk.
- (NSManagedObjectContext *)temporaryWriteContextReturn Value
NSManagedObjectContext of [CYCoreData liason].readContext
Discussion
Warning: It is not wise to change or save to this context directly. ONLY READ
Declared In
CYCoreData.h