Conforms to NSObject
Declared in RKMappingOperationDataSource.h

Overview

An object that adopts the RKMappingOperationDataSource protocol is responsible for the retrieval or creation of target objects within an RKMapperOperation or RKMappingOperation. A data source is responsible for meeting the requirements of the underlying data store implementation and must return a key-value coding compliant object instance that can be used as the target object of a mapping operation. It is also responsible for commiting any changes necessary to the underlying data store once a mapping operation has completed its work.

At a minimum, a data source must implement the mappingOperation:targetObjectForRepresentation:withMapping: method. This method is responsible for finding an existing object instance to be updated or creating a new object if no existing object could be found or the underlying data store does not support persistence. Object mapping operations which target NSObject derived classes will always result in mapping to new transient objects, while persistent data stores such as Core Data can be queried to retrieve existing objects for update.

Tasks

Instance Methods

commitChangesForMappingOperation:error:

Tells the data source to commit any changes to the underlying data store.

- (BOOL)commitChangesForMappingOperation:(RKMappingOperation *)mappingOperation error:(NSError **)error

Parameters

mappingOperation

The mapping operation that has completed its work.

error

A pointer to an error to be set in the event that the mapping operation could not be committed.

Return Value

A Boolean value indicating if the changes for the mapping operation were committed successfully.

Declared In

RKMappingOperationDataSource.h

mappingOperation:deleteExistingValueOfRelationshipWithMapping:error:

Tells the data source to delete the existing value for a relationship that has been mapped with an assignment policy of RKReplaceAssignmentPolicy.

- (BOOL)mappingOperation:(RKMappingOperation *)mappingOperation deleteExistingValueOfRelationshipWithMapping:(RKRelationshipMapping *)relationshipMapping error:(NSError **)error

Parameters

mappingOperation

The mapping operation that is executing.

relationshipMapping

The relationship mapping for which the existing value is being replaced.

error

A pointer to an error to be set in the event that the deletion operation could not be completed.

Return Value

A Boolean value indicating if the existing objects for the relationship were successfully deleted.

Declared In

RKMappingOperationDataSource.h

mappingOperation:targetObjectForRepresentation:withMapping:inRelationship:

Asks the data source for the target object for an object mapping operation given an NSDictionary representation of the object’s properties and the mapping object that will be used to perform the mapping.

- (id)mappingOperation:(RKMappingOperation *)mappingOperation targetObjectForRepresentation:(NSDictionary *)representation withMapping:(RKObjectMapping *)mapping inRelationship:(RKRelationshipMapping *)relationshipMapping

Parameters

mappingOperation

The mapping operation requesting the target object.

representation

A dictionary representation of the properties to be mapped onto the retrieved target object.

mapping

The object mapping to be used to perform a mapping from the representation to the target object.

Return Value

A key-value coding compliant object to perform the mapping on to.

Discussion

The representation value is a fragment of content from a deserialized response that has been identified as containing content that is mappable using the given mapping.

Declared In

RKMappingOperationDataSource.h

mappingOperationShouldSetUnchangedValues:

Asks the data source if it should set values for properties without checking that the value has been changed. This method can result in a performance improvement during mapping as the mapping operation will not attempt to assess the change state of the property being mapped.

- (BOOL)mappingOperationShouldSetUnchangedValues:(RKMappingOperation *)mappingOperation

Parameters

mappingOperation

The mapping operation that is querying the data source.

Return Value

YES if the mapping operation should disregard property change status, else NO.

Discussion

If this method is not implemented by the data source, then the mapping operation defaults to NO.

Declared In

RKMappingOperationDataSource.h