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:

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

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

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:

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

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

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:targetObjectForMapping:inRelationship:

- (id)mappingOperation:(RKMappingOperation *)mappingOperation targetObjectForMapping:(RKObjectMapping *)mapping inRelationship:(RKRelationshipMapping *)relationshipMapping
Discussion

Asks the data source for the target object for an object mapping operation the mapping object that will be used to perform the mapping.

If not implemented or it returns nil, then the mappingOperation:targetObjectForRepresentation:withMapping:inRelationship: method will be called to determine the target.

It is preferable to implement this method if the representation is not needed to determine the target object, as obtaining that value is somewhat expensive.

Parameters

mappingOperation

The mapping operation requesting the target object.

mapping

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

representation

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

Return Value

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

Declared In

RKMappingOperationDataSource.h

mappingOperation:targetObjectForRepresentation:withMapping:inRelationship:

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

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.

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.

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.

Declared In

RKMappingOperationDataSource.h

mappingOperationShouldCollectMappingInfo:

- (BOOL)mappingOperationShouldCollectMappingInfo:(RKMappingOperation *)mappingOperation
Discussion

Asks the data source if the mapping operation should collect RKMappingInfo information during the mapping (stored in the mappingInfo property). If not needed, it can be a substantially faster to skip it. The mappingInfo property will be nil if not collected.

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

Parameters

mappingOperation

The mapping operation that is querying the data source.

Return Value

YES if the mapping operation should collect mapping information, else NO.

Declared In

RKMappingOperationDataSource.h

mappingOperationShouldSetUnchangedValues:

- (BOOL)mappingOperationShouldSetUnchangedValues:(RKMappingOperation *)mappingOperation
Discussion

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.

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

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.

Declared In

RKMappingOperationDataSource.h

mappingOperationShouldSkipPropertyMapping:

- (BOOL)mappingOperationShouldSkipPropertyMapping:(RKMappingOperation *)mappingOperation