RKObjectMapping Class Reference
| Inherits from | NSObject |
| Conforms to | RKObjectMappingDefinition |
| Declared in | RKObjectMapping.h RKObjectMapping.m |
Overview
An object mapping defines the rules for transforming a key-value coding compliant object into another representation. The mapping is defined in terms of a source object class and a collection of rules defining how keyPaths should be transformed into target attributes and relationships.
There are two types of transformations possible:
- keyPath to attribute. Defines that the value found at the keyPath should be transformed and assigned to the property specified by the attribute. The transformation to be performed is determined by inspecting the type of the target property at runtime.
- keyPath to relationship. Defines that the value found at the keyPath should be transformed into another object instance and assigned to the property specified by the relationship. Relationships are processed using an object mapping as well.
Through the use of relationship mappings, an arbitrarily complex object graph can be mapped for you.
Instances of RKObjectMapping are used to configure RKObjectMappingOperation instances, which actually perform the mapping work. Both object loading and serialization are defined in terms of object mappings.
Tasks
Other Methods
-
objectClassThe target class this object mapping is defining rules for
property -
mappingsThe aggregate collection of attribute and relationship mappings within this object mapping
property -
attributeMappingsThe collection of attribute mappings within this object mapping
property -
relationshipMappingsThe collection of relationship mappings within this object mapping
property -
mappedKeyPathsThe collection of mappable keyPaths that are defined within this object mapping. These keyPaths refer to keys within the source object being mapped (i.e. the parsed JSON payload).
property -
rootKeyPathThe root keyPath for this object. When the object mapping is being used for serialization and a root keyPath has been defined, the serialized object will be nested under this root keyPath before being encoded for transmission to a remote system.
property -
setDefaultValueForMissingAttributesWhen YES, any attributes that have mappings defined but are not present within the source object will be set to nil, clearing any existing value.
property -
setNilForMissingRelationshipsWhen YES, any relationships that have mappings defined but are not present within the source object will be set to nil, clearing any existing value.
property -
performKeyValueValidationWhen YES, RestKit will invoke key-value validation at object mapping time.
property -
forceCollectionMappingForces the mapper to treat the mapped keyPath as a collection even if it does not return an array or a set of objects. This permits mapping where a dictionary identifies a collection of objects.
property -
dateFormattersAn array of NSDateFormatter objects to use when mapping string values into NSDate attributes on the target objectClass. Each date formatter will be invoked with the string value being mapped until one of the date formatters does not return nil.
property -
preferredDateFormatterThe NSDateFormatter instance for your application’s preferred date and time configuration. This date formatter will be used when generating string representations of NSDate attributes (i.e. during serialization to URL form encoded or JSON format).
property -
+ mappingForClass:Returns an object mapping for the specified class that is ready for configuration
-
+ serializationMappingReturns an object mapping useful for configuring a serialization mapping. The object class is configured as NSMutableDictionary
-
+ mappingForClass:block:Returns an object mapping targeting the specified class. The RKObjectMapping instance will be yieled to the block so that you can perform on the fly configuration without having to obtain a reference variable for the mapping.
-
+ serializationMappingWithBlock:Returns serialization mapping for encoding a local object to a dictionary for transport. The RKObjectMapping instance will be yieled to the block so that you can perform on the fly configuration without having to obtain a reference variable for the mapping.
-
– addAttributeMapping:Add a configured attribute mapping to this object mapping
-
– addRelationshipMapping:Add a configured attribute mapping to this object mapping
-
– mappingForKeyPath:Returns the attribute or relationship mapping for the given source keyPath.
-
– mappingForAttribute:Returns the attribute mapping targeting the specified attribute on the destination object
-
– mappingForRelationship:Returns the relationship mapping targeting the specified relationship on the destination object
-
– mapAttributes:Define an attribute mapping for one or more keyPaths where the source keyPath and destination attribute property have the same name.
-
– mapAttributesFromSet:Defines an attribute mapping for each string attribute in the collection where the source keyPath and the destination attribute property have the same name.
-
– mapAttributesFromArray:Defines an attribute mapping for each string attribute in the collection where the source keyPath and the destination attribute property have the same name.
-
– mapRelationship:withMapping:Defines a relationship mapping for a key where the source keyPath and the destination relationship property have the same name.
-
– hasMany:withMapping:Syntactic sugar to improve readability when defining a relationship mapping. Implies that the mapping targets a one-to-many relationship nested within the source data.
-
– hasOne:withMapping:Syntactic sugar to improve readability when defining a relationship mapping. Implies that the mapping targets a one-to-one relationship nested within the source data.
-
– mapKeyPath:toAttribute:Instantiate and add an RKObjectAttributeMapping instance targeting a keyPath within the mappable source data to an attribute on the target object.
-
– mapKeyPath:toRelationship:withMapping:Instantiate and add an RKObjectRelationshipMapping instance targeting a keyPath within the mappable source data to a relationship property on the target object.
-
– mapKeyPath:toRelationship:withMapping:serialize:Instantiate and add an RKObjectRelationshipMapping instance targeting a keyPath within the mappable source data to a relationship property on the target object.
-
– mapKeyPathsToAttributes:Quickly define a group of attribute mappings using alternating keyPath and attribute names. You must provide an equal number of keyPath and attribute pairs or an exception will be generated.
-
– mapKeyOfNestedDictionaryToAttribute:Configures a sub-key mapping for cases where JSON has been nested underneath a key named after an attribute.
-
– attributeMappingForKeyOfNestedDictionaryReturns the attribute mapping targeting the key of a nested dictionary in the source JSON. This attribute mapping corresponds to the attributeName configured via mapKeyOfNestedDictionaryToAttribute:
-
– removeAllMappingsRemoves all currently configured attribute and relationship mappings from the object mapping
-
– removeMapping:Removes an instance of an attribute or relationship mapping from the object mapping
-
– removeMappingForKeyPath:Remove the attribute or relationship mapping for the specified source keyPath
-
– inverseMappingGenerates an inverse mapping for the rules specified within this object mapping. This can be used to quickly generate a corresponding serialization mapping from a configured object mapping. The inverse mapping will have the source and destination keyPaths swapped for all attribute and relationship mappings.
-
– defaultValueForMissingAttribute:Returns the default value to be assigned to the specified attribute when it is missing from a mappable payload.
-
– mappableObjectForData:Returns an auto-released object that can be used to apply this object mapping given a set of mappable data. For transient objects, this generally returns an instance of the objectClass. For Core Data backed persistent objects, mappableData will be inspected to search for primary key data to lookup existing object instances.
-
– classForProperty:Returns the class of the attribute or relationship property of the target objectClass
DateAndTimeFormatting Methods
-
+ defaultDateFormattersReturns the collection of default date formatters that will be used for all object mappings that have not been configured specifically.
-
+ setDefaultDateFormatters:Sets the collection of default date formatters to the specified array. The array should contain configured instances of NSDateFormatter in the order in which you want them applied during object mapping operations.
-
+ addDefaultDateFormatter:Adds a date formatter instance to the default collection
-
+ addDefaultDateFormatterForString:inTimeZone:Convenience method for quickly constructing a date formatter and adding it to the collection of default date formatters. The locale is auto-configured to en_US_POSIX
-
+ preferredDateFormatterReturns the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct.
-
+ setPreferredDateFormatter:Sets the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct.
Properties
attributeMappings
The collection of attribute mappings within this object mapping
@property (nonatomic, readonly) NSArray *attributeMappingsDeclared In
RKObjectMapping.hdateFormatters
An array of NSDateFormatter objects to use when mapping string values into NSDate attributes on the target objectClass. Each date formatter will be invoked with the string value being mapped until one of the date formatters does not return nil.
@property (nonatomic, retain) NSArray *dateFormattersDiscussion
Defaults to the application-wide collection of date formatters configured via: [RKObjectMapping setDefaultDateFormatters:]
Declared In
RKObjectMapping.hforceCollectionMapping
Forces the mapper to treat the mapped keyPath as a collection even if it does not return an array or a set of objects. This permits mapping where a dictionary identifies a collection of objects.
@property (nonatomic, assign) BOOL forceCollectionMappingDiscussion
When enabled, each key/value pair in the resolved dictionary will be mapped as a separate entity. This is useful when you have a JSON structure similar to:
{ "users":
{
"blake": { "id": 1234, "email": "[email protected]" },
"rachit": { "id": 5678", "email": "[email protected]" }
}
}
By enabling forceCollectionMapping, RestKit will map “blake” => attributes and “rachit” => attributes as independent objects. This can be combined with mapKeyOfNestedDictionaryToAttribute: to properly map these sorts of structures.
@default NO
Declared In
RKObjectMapping.hmappedKeyPaths
The collection of mappable keyPaths that are defined within this object mapping. These keyPaths refer to keys within the source object being mapped (i.e. the parsed JSON payload).
@property (nonatomic, readonly) NSArray *mappedKeyPathsDeclared In
RKObjectMapping.hmappings
The aggregate collection of attribute and relationship mappings within this object mapping
@property (nonatomic, readonly) NSArray *mappingsDeclared In
RKObjectMapping.hobjectClass
The target class this object mapping is defining rules for
@property (nonatomic, assign) Class objectClassDeclared In
RKObjectMapping.hperformKeyValueValidation
When YES, RestKit will invoke key-value validation at object mapping time.
@property (nonatomic, assign) BOOL performKeyValueValidationDiscussion
Default: YES
Declared In
RKObjectMapping.hpreferredDateFormatter
The NSDateFormatter instance for your application’s preferred date and time configuration. This date formatter will be used when generating string representations of NSDate attributes (i.e. during serialization to URL form encoded or JSON format).
@property (nonatomic, retain) NSDateFormatter *preferredDateFormatterDiscussion
Defaults to the application-wide preferred date formatter configured via: [RKObjectMapping setPreferredDateFormatter:]
Declared In
RKObjectMapping.hrelationshipMappings
The collection of relationship mappings within this object mapping
@property (nonatomic, readonly) NSArray *relationshipMappingsDeclared In
RKObjectMapping.hrootKeyPath
The root keyPath for this object. When the object mapping is being used for serialization and a root keyPath has been defined, the serialized object will be nested under this root keyPath before being encoded for transmission to a remote system.
@property (nonatomic, retain) NSString *rootKeyPathSee Also
Declared In
RKObjectMapping.hsetDefaultValueForMissingAttributes
When YES, any attributes that have mappings defined but are not present within the source object will be set to nil, clearing any existing value.
@property (nonatomic, assign, getter=shouldSetDefaultValueForMissingAttributes) BOOL setDefaultValueForMissingAttributesDeclared In
RKObjectMapping.hsetNilForMissingRelationships
When YES, any relationships that have mappings defined but are not present within the source object will be set to nil, clearing any existing value.
@property (nonatomic, assign) BOOL setNilForMissingRelationshipsDeclared In
RKObjectMapping.hClass Methods
addDefaultDateFormatter:
Adds a date formatter instance to the default collection
+ (void)addDefaultDateFormatter:(NSDateFormatter *)dateFormatterParameters
- dateFormatter
An NSDateFormatter object to append to the end of the default formatters collection
See Also
Declared In
RKObjectMapping.haddDefaultDateFormatterForString:inTimeZone:
Convenience method for quickly constructing a date formatter and adding it to the collection of default date formatters. The locale is auto-configured to en_US_POSIX
+ (void)addDefaultDateFormatterForString:(NSString *)dateFormatString inTimeZone:(NSTimeZone *)nilOrTimeZoneParameters
- dateFormatString
The dateFormat string to assign to the newly constructed NSDateFormatter instance
- nilOrTimeZone
The NSTimeZone object to configure on the NSDateFormatter instance. Defaults to UTC time.
Return Value
A new NSDateFormatter will be appended to the defaultDateFormatters with the specified date format and time zone
Declared In
RKObjectMapping.hdefaultDateFormatters
Returns the collection of default date formatters that will be used for all object mappings that have not been configured specifically.
+ (NSArray *)defaultDateFormattersReturn Value
An array of NSDateFormatter objects used when mapping strings into NSDate attributes
Discussion
Out of the box, RestKit initializes the following default date formatters for you in the UTC time zone:
* yyyy-MM-dd'T'HH:mm:ss'Z'
* MM/dd/yyyy
Declared In
RKObjectMapping.hmappingForClass:
Returns an object mapping for the specified class that is ready for configuration
+ (id)mappingForClass:(Class)objectClassDeclared In
RKObjectMapping.hmappingForClass:block:
Returns an object mapping targeting the specified class. The RKObjectMapping instance will be yieled to the block so that you can perform on the fly configuration without having to obtain a reference variable for the mapping.
+ (id)mappingForClass:(Class)objectClass block:(void ( ^ ) ( RKObjectMapping *))blockDiscussion
For example, consider we have a one-off request that will load a few attributes for our object. Using blocks, this is very succinct:
[[RKObjectManager sharedManager] postObject:self delegate:self block:^(RKObjectLoader* loader) {
loader.objectMapping = [RKObjectMapping mappingForClass:[Person class] block:^(RKObjectMapping* mapping) {
[mapping mapAttributes:@"email", @"first_name", nil];
}];
}];
Declared In
RKObjectMapping.hpreferredDateFormatter
Returns the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct.
+ (NSDateFormatter *)preferredDateFormatterReturn Value
The preferred NSDateFormatter to use when serializing dates into strings
Discussion
Defaults to a date formatter configured for the UTC Time Zone with a format string of “yyyy-MM-dd HH:mm:ss Z”
Declared In
RKObjectMapping.hserializationMapping
Returns an object mapping useful for configuring a serialization mapping. The object class is configured as NSMutableDictionary
+ (id)serializationMappingDeclared In
RKObjectMapping.hserializationMappingWithBlock:
Returns serialization mapping for encoding a local object to a dictionary for transport. The RKObjectMapping instance will be yieled to the block so that you can perform on the fly configuration without having to obtain a reference variable for the mapping.
+ (id)serializationMappingWithBlock:(void ( ^ ) ( RKObjectMapping *))blockDiscussion
For example, consider we have a one-off request within which we want to post a subset of our object data. Using blocks, this is very succinct:
- (BOOL)changePassword:(NSString*)newPassword error:(NSError**)error {
if ([self validatePassword:newPassword error:error]) {
self.password = newPassword;
[[RKObjectManager sharedManager] putObject:self delegate:self block:^(RKObjectLoader* loader) {
loader.serializationMapping = [RKObjectMapping serializationMappingWithBlock:^(RKObjectMapping* mapping) {
[mapping mapAttributes:@"password", nil];
}];
}];
}
}
Using the block forms we are able to quickly configure and send this request on the fly.
Declared In
RKObjectMapping.hsetDefaultDateFormatters:
Sets the collection of default date formatters to the specified array. The array should contain configured instances of NSDateFormatter in the order in which you want them applied during object mapping operations.
+ (void)setDefaultDateFormatters:(NSArray *)dateFormattersParameters
- dateFormatters
An array of date formatters to replace the existing defaults
See Also
Declared In
RKObjectMapping.hsetPreferredDateFormatter:
Sets the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct.
+ (void)setPreferredDateFormatter:(NSDateFormatter *)dateFormatterParameters
- dateFormatter
The NSDateFormatter to configured as the new preferred instance
Declared In
RKObjectMapping.hInstance Methods
addAttributeMapping:
Add a configured attribute mapping to this object mapping
- (void)addAttributeMapping:(RKObjectAttributeMapping *)mappingSee Also
Declared In
RKObjectMapping.haddRelationshipMapping:
Add a configured attribute mapping to this object mapping
- (void)addRelationshipMapping:(RKObjectRelationshipMapping *)mappingSee Also
Declared In
RKObjectMapping.hattributeMappingForKeyOfNestedDictionary
Returns the attribute mapping targeting the key of a nested dictionary in the source JSON. This attribute mapping corresponds to the attributeName configured via mapKeyOfNestedDictionaryToAttribute:
- (RKObjectAttributeMapping *)attributeMappingForKeyOfNestedDictionaryReturn Value
An attribute mapping for the key of a nested dictionary being mapped or nil
Declared In
RKObjectMapping.hclassForProperty:
Returns the class of the attribute or relationship property of the target objectClass
- (Class)classForProperty:(NSString *)propertyNameParameters
- propertyName
The name of the property we would like to retrieve the type of
Discussion
Given the name of a string property, this will return an NSString, etc.
Declared In
RKObjectMapping.hdefaultValueForMissingAttribute:
Returns the default value to be assigned to the specified attribute when it is missing from a mappable payload.
- (id)defaultValueForMissingAttribute:(NSString *)attributeNameDiscussion
The default implementation returns nil for transient object mappings. On managed object mappings, the default value returned from the Entity definition will be used.
Declared In
RKObjectMapping.hhasMany:withMapping:
Syntactic sugar to improve readability when defining a relationship mapping. Implies that the mapping targets a one-to-many relationship nested within the source data.
- (void)hasMany:(NSString *)keyPath withMapping:(id<RKObjectMappingDefinition>)objectOrDynamicMappingDeclared In
RKObjectMapping.hhasOne:withMapping:
Syntactic sugar to improve readability when defining a relationship mapping. Implies that the mapping targets a one-to-one relationship nested within the source data.
- (void)hasOne:(NSString *)keyPath withMapping:(id<RKObjectMappingDefinition>)objectOrDynamicMappingDeclared In
RKObjectMapping.hinverseMapping
Generates an inverse mapping for the rules specified within this object mapping. This can be used to quickly generate a corresponding serialization mapping from a configured object mapping. The inverse mapping will have the source and destination keyPaths swapped for all attribute and relationship mappings.
- (RKObjectMapping *)inverseMappingDeclared In
RKObjectMapping.hmapAttributes:
Define an attribute mapping for one or more keyPaths where the source keyPath and destination attribute property have the same name.
- (void)mapAttributes:(NSString *)attributeKey, ...Parameters
- attributeKey
A key-value coding key corresponding to a value in the mappable source object and an attribute on the destination class that have the same name.
Discussion
For example, given the transformation from a JSON dictionary:
{"name": "My Name", "age": 28}
To a Person class with corresponding name & age properties, we could configure the attribute mappings via:
[mapping mapAttributes:@"name", @"age", nil];
Declared In
RKObjectMapping.hmapAttributesFromArray:
Defines an attribute mapping for each string attribute in the collection where the source keyPath and the destination attribute property have the same name.
- (void)mapAttributesFromArray:(NSArray *)setParameters
- array
An array of string attribute keyPaths to deifne mappings for
Discussion
For example, given the transformation from a JSON dictionary:
{"name": "My Name", "age": 28}
To a Person class with corresponding name & age properties, we could configure the attribute mappings via:
[mapping mapAttributesFromSet:[NSArray arrayWithObjects:@"name", @"age", nil]];
Declared In
RKObjectMapping.hmapAttributesFromSet:
Defines an attribute mapping for each string attribute in the collection where the source keyPath and the destination attribute property have the same name.
- (void)mapAttributesFromSet:(NSSet *)setParameters
- set
A set of string attribute keyPaths to deifne mappings for
Discussion
For example, given the transformation from a JSON dictionary:
{"name": "My Name", "age": 28}
To a Person class with corresponding name & age properties, we could configure the attribute mappings via:
[mapping mapAttributesFromSet:[NSSet setWithObjects:@"name", @"age", nil]];
Declared In
RKObjectMapping.hmapKeyOfNestedDictionaryToAttribute:
Configures a sub-key mapping for cases where JSON has been nested underneath a key named after an attribute.
- (void)mapKeyOfNestedDictionaryToAttribute:(NSString *)attributeNameDiscussion
For example, consider the following JSON:
{ "users":
{
"blake": { "id": 1234, "email": "[email protected]" },
"rachit": { "id": 5678", "email": "[email protected]" }
}
}
We can configure our mappings to handle this in the following form:
RKObjectMapping* mapping = [RKObjectMapping mappingForClass:[User class]];
mapping.forceCollectionMapping = YES; // RestKit cannot infer this is a collection, so we force it
[mapping mapKeyOfNestedDictionaryToAttribute:@"firstName"];
[mapping mapFromKeyPath:@"(firstName).id" toAttribute:"userID"];
[mapping mapFromKeyPath:@"(firstName).email" toAttribute:"email"];
[[RKObjectManager sharedManager].mappingProvider setObjectMapping:mapping forKeyPath:@"users"];
Declared In
RKObjectMapping.hmapKeyPath:toAttribute:
Instantiate and add an RKObjectAttributeMapping instance targeting a keyPath within the mappable source data to an attribute on the target object.
- (void)mapKeyPath:(NSString *)sourceKeyPath toAttribute:(NSString *)destinationAttributeParameters
- sourceKeyPath
A key-value coding keyPath to fetch the mappable value from
- destinationAttribute
The attribute name to assign the mapped value to
Discussion
Used to quickly define mappings where the source value is deeply nested in the mappable data or the source and destination do not have corresponding names.
Examples:
// We want to transform the name to something Cocoa-esque
[mapping mapKeyPath:@"created_at" toAttribute:@"createdAt"];
// We want to extract nested data and map it to a property
[mapping mapKeyPath:@"results.metadata.generated_on" toAttribute:@"generationTimestamp"];
See Also
Declared In
RKObjectMapping.hmapKeyPath:toRelationship:withMapping:
Instantiate and add an RKObjectRelationshipMapping instance targeting a keyPath within the mappable source data to a relationship property on the target object.
- (void)mapKeyPath:(NSString *)sourceKeyPath toRelationship:(NSString *)destinationRelationship withMapping:(id<RKObjectMappingDefinition>)objectOrDynamicMappingParameters
- sourceKeyPath
A key-value coding keyPath to fetch the mappable value from
- destinationRelationship
The relationship name to assign the mapped value to
- objectMapping
An object mapping to use when processing the nested objects
Discussion
Used to quickly define mappings where the source value is deeply nested in the mappable data or the source and destination do not have corresponding names.
Examples:
// We want to transform the name to something Cocoa-esque
[mapping mapKeyPath:@"best_friend" toRelationship:@"bestFriend" withObjectMapping:friendMapping];
// We want to extract nested data and map it to a property
[mapping mapKeyPath:@"best_friend.favorite_cat" toRelationship:@"bestFriendsFavoriteCat" withObjectMapping:catMapping];
See Also
Declared In
RKObjectMapping.hmapKeyPath:toRelationship:withMapping:serialize:
Instantiate and add an RKObjectRelationshipMapping instance targeting a keyPath within the mappable source data to a relationship property on the target object.
- (void)mapKeyPath:(NSString *)relationshipKeyPath toRelationship:(NSString *)keyPath withMapping:(id<RKObjectMappingDefinition>)objectOrDynamicMapping serialize:(BOOL)serializeParameters
- serialize
A boolean value indicating whether to include this relationship in serialization
- destinationRelationship
The relationship name to assign the mapped value to
- objectMapping
An object mapping to use when processing the nested objects
- sourceKeyPath
A key-value coding keyPath to fetch the mappable value from
Discussion
Used to indicate whether the relationship should be included in serialization.
Declared In
RKObjectMapping.hmapKeyPathsToAttributes:
Quickly define a group of attribute mappings using alternating keyPath and attribute names. You must provide an equal number of keyPath and attribute pairs or an exception will be generated.
- (void)mapKeyPathsToAttributes:(NSString *)sourceKeyPath, ...Parameters
- sourceKeyPath
A key-value coding key path to fetch a mappable value from
- ...
A nil-terminated sequence of strings alternating between source key paths and destination attributes
Discussion
For example:
[personMapping mapKeyPathsToAttributes:@"name", @"name", @"createdAt", @"createdAt", @"street_address", @"streetAddress", nil];
Declared In
RKObjectMapping.hmapRelationship:withMapping:
Defines a relationship mapping for a key where the source keyPath and the destination relationship property have the same name.
- (void)mapRelationship:(NSString *)relationshipKey withMapping:(id<RKObjectMappingDefinition>)objectOrDynamicMappingParameters
- relationshipKey
A key-value coding key corresponding to a value in the mappable source object and a property
on the destination class that have the same name.
- objectOrDynamicMapping
An RKObjectMapping or RKObjectDynamic mapping to apply when mapping the relationship
Discussion
For example, given the transformation from a JSON dictionary:
{“name”: “My Name”, “age”: 28, “cat”: { “name”: “Asia” } }
To a Person class with corresponding ‘cat’ relationship property, we could configure the mappings via:
RKObjectMapping* catMapping = [RKObjectMapping mappingForClass:[Cat class]];
[personMapping mapRelationship:@"cat" withObjectMapping:catMapping];
Declared In
RKObjectMapping.hmappableObjectForData:
Returns an auto-released object that can be used to apply this object mapping given a set of mappable data. For transient objects, this generally returns an instance of the objectClass. For Core Data backed persistent objects, mappableData will be inspected to search for primary key data to lookup existing object instances.
- (id)mappableObjectForData:(id)mappableDataDeclared In
RKObjectMapping.hmappingForAttribute:
Returns the attribute mapping targeting the specified attribute on the destination object
- (RKObjectAttributeMapping *)mappingForAttribute:(NSString *)attributeKeyParameters
- attributeKey
The name of the attribute we want to retrieve the mapping for
Declared In
RKObjectMapping.hmappingForKeyPath:
Returns the attribute or relationship mapping for the given source keyPath.
- (id)mappingForKeyPath:(NSString *)sourceKeyPathParameters
- sourceKeyPath
A keyPath within the mappable source object that is mapped to an attribute or relationship in this object mapping.
Declared In
RKObjectMapping.hmappingForRelationship:
Returns the relationship mapping targeting the specified relationship on the destination object
- (RKObjectRelationshipMapping *)mappingForRelationship:(NSString *)relationshipKeyParameters
- relationshipKey
The name of the relationship we want to retrieve the mapping for
Declared In
RKObjectMapping.hremoveAllMappings
Removes all currently configured attribute and relationship mappings from the object mapping
- (void)removeAllMappingsDeclared In
RKObjectMapping.hremoveMapping:
Removes an instance of an attribute or relationship mapping from the object mapping
- (void)removeMapping:(RKObjectAttributeMapping *)attributeOrRelationshipMappingParameters
- attributeOrRelationshipMapping
The attribute or relationship mapping to remove
Declared In
RKObjectMapping.hremoveMappingForKeyPath:
Remove the attribute or relationship mapping for the specified source keyPath
- (void)removeMappingForKeyPath:(NSString *)sourceKeyPathParameters
- sourceKeyPath
A key-value coding key path to remove the mappings for
Declared In
RKObjectMapping.h