Inherits from RKPropertyMapping : NSObject
Declared in RKRelationshipMapping.h

Overview

The RKRelationshipMapping class is used to describe relationships of a class in an RKObjectMapping or an entity in an RKEntityMapping object.

RKRelationshipMapping extends RKPropertyMapping to describe features specific to relationships, including the RKMapping object describing how to map the destination object.

Tasks

Creating a Relationship Mapping

Accessing the Destination Mapping

  •   mapping

    An RKMapping object describing how to map the object representation at sourceKeyPath to a new represenation at destinationKeyPath.

    property

Properties

mapping

An RKMapping object describing how to map the object representation at sourceKeyPath to a new represenation at destinationKeyPath.

@property (nonatomic, strong, readonly) RKMapping *mapping

Declared In

RKRelationshipMapping.h

Class Methods

relationshipMappingFromKeyPath:toKeyPath:withMapping:

Creates and returns a new relationship mapping object describing how to transform a related object representation at sourceKeyPath to a new representation at destinationKeyPath using the given mapping.

+ (RKRelationshipMapping *)relationshipMappingFromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKMapping *)mapping

Parameters

sourceKeyPath

A key path from which to retrieve data in the source object representation that is to be mapped as a relationship.

destinationKeyPath

The key path on the destination object to set the object mapped results.

mapping

A mapping object describing how to map the data retrieved from sourceKeyPath that is to be set on destinationKeyPath.

Discussion

The mapping may describe a to-one or a to-many relationship. The appropriate handling of the source representation is deferred until run-time and is determined by performing reflection on the data retrieved from the source object representation by sending a valueForKeyPath: message where the key path is the value given in sourceKeyPath. If an NSArray, NSSet or NSOrderedSet object is returned, the related object representation is processed as a to-many collection. Otherwise the representation is considered to be a to-one.

Declared In

RKRelationshipMapping.h