|ReleasedLast Release||Dec 2014|
Maintained by Unclaimed.
CRLoom is a framework for helping with the import, update and querying of
This is an
NSOperation subclass that created via
+ (instanceType)operationWithData:(id)data managedObjectClass:(Class)class guaranteedInsert:(BOOL)guaranteedInsert saveOnBatchSize:(NSUInteger)batchSize pruneMissingObjects:(BOOL)pruneMissingObjects useCache:(BOOL)useCache error:(NSError* __autoreleasing *)error;
This operation can be added to an
NSOperationQueue and will thread the work of importing the data. Setting
YES will have the operation provide an
NSCache to the thread doing the import work that will be used as a first layer to check to find existing objects before entire fetch requests are used.
This is a category that provides a generic implementation for importing and finding
NSManagedObjects. The import and search methods take an
NSManagedObjectContext as a parameter so they can work on different threads.
+ (NSArray*)importData:(id)data intoContext:(NSManagedObjectContext*)moc withCache:(NSCache*)cache guaranteedInsert:(BOOL)guaranteedInsert saveOnBatchSize:(NSUInteger)batchSize error:(NSError* __autoreleasing *)error;
A cache can be provided to be used as a first check place for existing objects when processing this data into
NSManagedObjects. Providing a cache here will ensure that those shared objects when created or retrieved for the first time will be held in a cache to reduce the total amount of fetch requests made.
+ (instancetype)existingObjectWithIdentifierValue:(id)value inContext:(NSManagedObjectContext*)moc withCache:(NSCache*)cache error:(NSError* __autoreleasing *)error;
For these methods to work for a given
NSManagedObject subclass must implement a few methods. The methods that need to be implemented provided by the
A method that returns the model (Core Data) key that represents the object's unique identifier
A method that returns the key that represents the object's unique identifier in the data being imported (e.g. key in JSON from your API)
A method to update the object with data from the api. This allows work to be done on any given context should ensure error delivery, the cache will be used as a first layer for getting existing relationship objects before a full fetch request to core data is done.
- (BOOL)updateWithData:(NSDictionary*)data intoContext:(NSManagedObjectContext*)moc withCache:(NSCache*)cache error:(NSError**)error;
A method to indicate whether a model's data is identical to an
NSDictionary representation of that object.
NSManagedObject subclass can also optionally implement methods to return the
NSPredicate that should be used to "match" objects.
+ (NSPredicate*)predicateWithIdentiferValue:(id)identifierValue; + (NSPredicate*)predicateWithIdentiferCollection:(NSArray*)identifierCollection;