RKManagedObjectMapping Class Reference
| Inherits from | RKObjectMapping : RKObjectMappingDefinition : NSObject |
| Declared in | RKManagedObjectMapping.h RKManagedObjectMapping.m |
Tasks
Other Methods
-
+ mappingForClass:inManagedObjectStore:Creates a new object mapping targetting the Core Data entity represented by objectClass
-
+ mappingForEntity:inManagedObjectStore:Creates a new object mapping targetting the specified Core Data entity
-
+ mappingForEntityWithName:inManagedObjectStore:Creates a new object mapping targetting the Core Data entity with the specified name. The entity description is fetched from the managed object context associated with objectStore
-
entityThe Core Data entity description used for this object mapping
property -
primaryKeyAttributeThe name of the attribute on the destination entity that acts as the primary key for instances of the entity in the remote backend system. Used to uniquely identify objects within the store so that existing objects are updated rather than creating new ones.
property -
relationshipsAndPrimaryKeyAttributesReturns a dictionary containing Core Data relationships and attribute pairs containing the primary key for
property -
objectStoreThe RKManagedObjectStore containing the Core Data entity being mapped
property -
– connectRelationship:withObjectForPrimaryKeyAttribute:Instructs RestKit to automatically connect a relationship of the object being mapped by looking up the related object by primary key.
-
– 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:. -
– connectRelationship:withObjectForPrimaryKeyAttribute:whenValueOfKeyPath:isEqualTo:Conditionally connect a relationship of the object being mapped when the object being mapped has keyPath equal to a specified value.
-
– connectRelationship:withObjectForPrimaryKeyAttribute:usingEvaluationBlock:Conditionally connect a relationship of the object being mapped when the object being mapped has block evaluate to YES. This variant is useful in cases where you want to execute an arbitrary block to determine whether or not to connect a relationship.
-
– initWithEntity:inManagedObjectStore:Initialize a managed object mapping with a Core Data entity description and a RestKit managed object store
-
– 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.
Other Methods
-
+ mappingForClass:Returns an object mapping for the specified class that is ready for configuration
-
– 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
Properties
entity
The Core Data entity description used for this object mapping
@property (nonatomic, readonly) NSEntityDescription *entityDeclared In
RKManagedObjectMapping.hobjectStore
The RKManagedObjectStore containing the Core Data entity being mapped
@property (nonatomic, readonly) RKManagedObjectStore *objectStoreDeclared In
RKManagedObjectMapping.hprimaryKeyAttribute
The name of the attribute on the destination entity that acts as the primary key for instances of the entity in the remote backend system. Used to uniquely identify objects within the store so that existing objects are updated rather than creating new ones.
@property (nonatomic, retain) NSString *primaryKeyAttributeDiscussion
Warning: Note that primaryKeyAttribute defaults to the primaryKeyAttribute configured on the NSEntityDescription for the entity targetted by the receiving mapping. This provides flexibility in cases where a single entity is the target of many mappings with differing primary key definitions.
If the primaryKeyAttribute is set on an RKManagedObjectMapping that targets an entity with a nil primaryKeyAttribute, then the primaryKeyAttribute will be set on the entity as well for convenience and backwards compatibility. This may change in the future.
Declared In
RKManagedObjectMapping.hClass Methods
mappingForClass:
Returns an object mapping for the specified class that is ready for configuration
+ (id)mappingForClass:(Class)objectClassDeclared In
RKObjectMapping.hmappingForClass:inManagedObjectStore:
Creates a new object mapping targetting the Core Data entity represented by objectClass
+ (id)mappingForClass:(Class)objectClass inManagedObjectStore:(RKManagedObjectStore *)objectStoreDeclared In
RKManagedObjectMapping.hmappingForEntity:inManagedObjectStore:
Creates a new object mapping targetting the specified Core Data entity
+ (RKManagedObjectMapping *)mappingForEntity:(NSEntityDescription *)entity inManagedObjectStore:(RKManagedObjectStore *)objectStoreDeclared In
RKManagedObjectMapping.hmappingForEntityWithName:inManagedObjectStore:
Creates a new object mapping targetting the Core Data entity with the specified name. The entity description is fetched from the managed object context associated with objectStore
+ (RKManagedObjectMapping *)mappingForEntityWithName:(NSString *)entityName inManagedObjectStore:(RKManagedObjectStore *)objectStoreDeclared In
RKManagedObjectMapping.hInstance Methods
classForProperty:
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.hconnectRelationship: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 *)primaryKeyAttributeDiscussion
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.hconnectRelationship:withObjectForPrimaryKeyAttribute:usingEvaluationBlock:
Conditionally connect a relationship of the object being mapped when the object being mapped has block evaluate to YES. This variant is useful in cases where you want to execute an arbitrary block to determine whether or not to connect a relationship.
- (void)connectRelationship:(NSString *)relationshipName withObjectForPrimaryKeyAttribute:(NSString *)primaryKeyAttribute usingEvaluationBlock:(BOOL ( ^ ) ( id data ))blockDiscussion
For example, given a Project object associated with a User, where the ‘admin’ relationship is specified by a adminID property on the managed object:
[mapping connectRelationship:@“admin” withObjectForPrimaryKeyAttribute:@“adminID” usingEvaluationBlock:^(id data) {
return [User isAuthenticated];
}];
Will hydrate the ‘admin’ 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. Note that this connection will only occur when the provided block evalutes to YES. In cases where no match occurs, the relationship connection is skipped.
Declared In
RKManagedObjectMapping.hconnectRelationship:withObjectForPrimaryKeyAttribute:whenValueOfKeyPath:isEqualTo:
Conditionally connect a relationship of the object being mapped when the object being mapped has keyPath equal to a specified value.
- (void)connectRelationship:(NSString *)relationshipName withObjectForPrimaryKeyAttribute:(NSString *)primaryKeyAttribute whenValueOfKeyPath:(NSString *)keyPath isEqualTo:(id)valueDiscussion
For example, given a Project object associated with a User, where the ‘admin’ relationship is specified by a adminID property on the managed object:
[mapping connectRelationship:@“admin” withObjectForPrimaryKeyAttribute:@“adminID” whenValueOfKeyPath:@“userType” isEqualTo:@“Admin”];
Will hydrate the ‘admin’ 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. Note that this connection will only occur when the Product’s ‘userType’ property equals ‘Admin’. In cases where no match occurs, the relationship connection is skipped.
Declared In
RKManagedObjectMapping.hconnectRelationshipsWithObjectsForPrimaryKeyAttributes:
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.hdefaultValueForMissingAttribute:
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 *)attributeNameDeclared In
RKManagedObjectMapping.hinitWithEntity:inManagedObjectStore:
Initialize a managed object mapping with a Core Data entity description and a RestKit managed object store
- (id)initWithEntity:(NSEntityDescription *)entity inManagedObjectStore:(RKManagedObjectStore *)objectStoreDeclared In
RKManagedObjectMapping.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.h