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
NSManagedObjectID
for 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 anRKManagedObjectResponseMapperOperation
against aNSManagedObject
targetObject with a temporary ID. - Persisting Mapped Objects: Instances of
RKManagedObjectResponseMapperOperation
do NOT perform any persistence on theNSManagedObject
in 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
-
managedObjectContext
The managed object context in which the mapping will be performed.
property -
managedObjectCache
An object implementing the
propertyRKManagedObjectCaching
protocol to be used for retrieving existingNSManagedObject
instances 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. -
targetObjectID
The permanent
propertyNSManagedObjectID
for the target object of the mapping operation. During mapping, an instance local to themanagedObjectContext
is 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> managedObjectCache
Declared In
RKResponseMapperOperation.h
managedObjectContext
The managed object context in which the mapping will be performed.
@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext
Discussion
Warning: The NSManagedObjectContext
given must have a concurrencyType
of either NSPrivateQueueConcurrencyType
or NSMainQueueConcurrencyType
. Thread confined contexts are not supported.
Declared In
RKResponseMapperOperation.h
targetObjectID
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 *targetObjectID
Discussion
If nil
and the targetObject
is a managed object, the objectID
of the target object will be used.
Declared In
RKResponseMapperOperation.h