Inherits from RKObjectMapping : NSObject
Declared in RKManagedObjectMapping.h
RKManagedObjectMapping.m

Tasks

Other Methods

Other Methods

  • + mappingForClass:

    Returns an object mapping for the specified class that is ready for configuration

Other Methods

  • – 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.

Other Methods

Properties

entity

The Core Data entity description used for this object mapping

@property (nonatomic, readonly) NSEntityDescription *entity

Declared In

RKManagedObjectMapping.h

primaryKeyAttribute

The attribute containing the primary key value for the class. This is consulted by RestKit to uniquely identify objects within the store using the primary key in your remote backend system.

@property (nonatomic, retain) NSString *primaryKeyAttribute

Declared In

RKManagedObjectMapping.h

relationshipsAndPrimaryKeyAttributes

Returns a dictionary containing Core Data relationships and attribute pairs containing the primary key for

@property (nonatomic, readonly) NSDictionary *relationshipsAndPrimaryKeyAttributes

Declared In

RKManagedObjectMapping.h

Class Methods

mappingForClass:

Returns an object mapping for the specified class that is ready for configuration

+ (id)mappingForClass:(Class)objectClass

Declared In

RKObjectMapping.h

mappingForEntity:

Creates a new object mapping targetting the specified Core Data entity

+ (RKManagedObjectMapping *)mappingForEntity:(NSEntityDescription *)entity

Declared In

RKManagedObjectMapping.h

mappingForEntityWithName:

Creates a new object mapping targetting the Core Data entity with the specified name. The entity description is fetched from the current managed object context

+ (RKManagedObjectMapping *)mappingForEntityWithName:(NSString *)entityName

Declared In

RKManagedObjectMapping.h

Instance Methods

classForProperty:

Returns the class of the attribute or relationship property of the target objectClass

- (Class)classForProperty:(NSString *)propertyName

Parameters

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.h

connectRelationship:withObjectForPrimaryKeyAttribute:

Instructs RestKit to automatically connect a relationship of the object being mapped by looking up the related object by primary key.

- (void)connectRelationship:(NSString *)relationshipName withObjectForPrimaryKeyAttribute:(NSString *)primaryKeyAttribute

Discussion

For example, given a Project object associated with a User, where the ‘user’ relationship is specified by a userID property on the managed object:

[mapping connectRelationship:@“user” withObjectForPrimaryKeyAttribute:@“userID”];

Will hydrate the ‘user’ association on the managed object with the object in the local object graph having the primary key specified in the managed object’s userID property.

In effect, this approach allows foreign key relationships between managed objects to be automatically maintained from the server to the underlying Core Data object graph.

Declared In

RKManagedObjectMapping.h

connectRelationshipsWithObjectsForPrimaryKeyAttributes:

Connects relationships using the primary key values contained in the specified attribute. This method is a short-cut for repeated invocation of connectRelationship:withObjectForPrimaryKeyAttribute:.

- (void)connectRelationshipsWithObjectsForPrimaryKeyAttributes:(NSString *)firstRelationshipName, ...

Declared In

RKManagedObjectMapping.h

defaultValueForMissingAttribute:

Returns the default value for the specified attribute as expressed in the Core Data entity definition. This value will be assigned if the object mapping is applied and a value for a missing attribute is not present in the payload.

- (id)defaultValueForMissingAttribute:(NSString *)attributeName

Declared In

RKManagedObjectMapping.h

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.

- (id)mappableObjectForData:(id)mappableData

Declared In

RKObjectMapping.h