Instance Method

didAccessValueForKey:

Provides support for key-value observing access notification.

Declaration

- (void)didAccessValueForKey:(NSString *)key;

Parameters

key

The name of one of the receiver's properties.

Discussion

Together with willAccessValueForKey:, this method is used to fire faults, to maintain inverse relationships, and so on. Each read access must be wrapped in this method pair (in the same way that each write access must be wrapped in the willChangeValueForKey:/didChangeValueForKey: method pair). In the default implementation of NSManagedObject these methods are invoked for you automatically. If, say, you create a custom subclass that uses explicit instance variables, you must invoke them yourself, as in the following example.

- (NSString *)firstName
{
    [self willAccessValueForKey:@"firstName"];
    NSString *rtn = firstName;
    [self didAccessValueForKey:@"firstName"];
    return rtn;
}

See Also

Supporting Key-Value Observing

+ automaticallyNotifiesObserversForKey:

Returns a Boolean value that indicates whether the receiver provides automatic support for key-value observing change notifications for the given key.

- observationInfo

Returns the observation info of the managed object.

- setObservationInfo:

Sets the observation info of the managed object.

- willAccessValueForKey:

Provides support for key-value observing access notification.

- didChangeValueForKey:

Provides an opportunity to respond when a value of a given property has changed.

- didChangeValueForKey:withSetMutation:usingObjects:

Provides an opportunity to respond when a change was made to a specified to-many relationship.

- willChangeValueForKey:

Provides an opportunity to respond when a value of a given property is about to change.

- willChangeValueForKey:withSetMutation:usingObjects:

Provides an opportunity to respond when a change is about to be made to a specified to-many relationship.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software