Instance Method


Returns the relationship for the given relationship of the object with a given object ID.


- (id)newValueForRelationship:(NSRelationshipDescription *)relationship forObjectWithID:(NSManagedObjectID *)objectID withContext:(NSManagedObjectContext *)context error:(NSError * _Nullable *)error;



The relationship for which values are requested.


The ID of the object for which values are requested.


The managed object context into which values will be returned.


If an error occurs, upon return contains an NSError object that describes the problem.

Return Value

The value of the relationship specified relationship of the object with object ID objectID, or nil if an error occurs.


If the relationship is a to-one, the method should return an NSManagedObjectID instance that identifies the destination, or an instance of NSNull if the relationship value is nil.

If the relationship is a to-many, the method should return a collection object containing NSManagedObjectID instances to identify the related objects. Using an NSArray instance is preferred because it will be the most efficient. A store may also return an instance of NSSet or NSOrderedSet; an instance of NSDictionary is not acceptable.

If an object with object ID objectID cannot be found, the method should return nil and—if error is not NULL—create and return an appropriate error object in error.

See Also

Manipulating Managed Objects

- executeRequest:withContext:error:

Returns a value as appropriate for the given request, or nil if the request cannot be completed.

- newValuesForObjectWithID:withContext:error:

Returns an incremental store node encapsulating the persistent external values of the object with a given object ID.

- obtainPermanentIDsForObjects:error:

Returns an array containing the object IDs for a given array of newly-inserted objects.

- newObjectIDForEntity:referenceObject:

Returns a new object ID that uses given data as the key.

- referenceObjectForObjectID:

Returns the reference data used to construct a given object ID.