RKManagedObjectResponseMapperOperation Class Reference
| Inherits from | RKResponseMapperOperation : NSOperation |
| Declared in | RKResponseMapperOperation.h |
Overview
RKManagedObjectResponseMapperOperation is an RKResponseMapperOperation subclass that provides support for performing object mapping using RKEntityMapping objects that target NSManagedObject derived classes. It requires an NSManagedObjectContext and a configured RKManagedObjectMappingOperationDataSource data source to execute successfully.
Performing response mapping that targets Core Data managed objects imposes some additional constraints on the process that the developer should understand thoroughly:
- Permanent Managed Object IDs: When using managed object contexts in a parent-child configuration, it is important to obtain a permanent
NSManagedObjectIDfor any existing objects that are to be mapped. Mapping that occur against objecs with temporary managedObjectID’s cannot be retrieved across contexts by ID. If executing anRKManagedObjectResponseMapperOperationagainst aNSManagedObjecttargetObject with a temporary ID. - Persisting Mapped Objects: Instances of
RKManagedObjectResponseMapperOperationdo NOT perform any persistence on theNSManagedObjectin which the mapping occurs. This is by design and ensures that the operation can be used to compose higher level components that handle persistence. It is the developer’s responsibility to ensure that the mapped managed objects are eventually persisted.
Tasks
Configuring Core Data
-
managedObjectContextThe managed object context in which the mapping will be performed.
property -
managedObjectCacheAn object implementing the
propertyRKManagedObjectCachingprotocol to be used for retrieving existingNSManagedObjectinstances by identification attributes. Ifnil, existing object cannot be retrieved and new objects will be created for all mappable content within the response data, likely resulting in the creation of duplicate objects. -
targetObjectIDThe permanent
propertyNSManagedObjectIDfor the target object of the mapping operation. During mapping, an instance local to themanagedObjectContextis fetched and used to perform the mapping operation.
Properties
managedObjectCache
An object implementing the RKManagedObjectCaching protocol to be used for retrieving existing NSManagedObject instances by identification attributes. If nil, existing object cannot be retrieved and new objects will be created for all mappable content within the response data, likely resulting in the creation of duplicate objects.
@property (nonatomic, weak) id<RKManagedObjectCaching> managedObjectCacheDeclared In
RKResponseMapperOperation.hmanagedObjectContext
The managed object context in which the mapping will be performed.
@property (nonatomic, strong) NSManagedObjectContext *managedObjectContextDiscussion
Warning: The NSManagedObjectContext given must have a concurrencyType of either NSPrivateQueueConcurrencyType or NSMainQueueConcurrencyType. Thread confined contexts are not supported.
Declared In
RKResponseMapperOperation.htargetObjectID
The permanent NSManagedObjectID for the target object of the mapping operation. During mapping, an instance local to the managedObjectContext is fetched and used to perform the mapping operation.
@property (nonatomic, copy) NSManagedObjectID *targetObjectIDDiscussion
If nil and the targetObject is a managed object, the objectID of the target object will be used.
Declared In
RKResponseMapperOperation.h