About Cocoa Bindings

Two primary APIs for Cocoa Bindings (

  • Key Value Coding  (valueForKey: to read attribute, setValue:forKey: to write) – using this, we can access properties of any class, used for NSManagedObject)
  • Key Value Observing (request notifications when 1 attribute has changed).

addObserver:self  forKeyPath:@”name” options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:@”context”];

so when there is a change for this attribute  -observeValueForKeyPath: ofObject: change: context: is called.

enum {
   NSKeyValueChangeSetting = 1,
   NSKeyValueChangeInsertion = 2,
   NSKeyValueChangeRemoval = 3,
   NSKeyValueChangeReplacement = 4
typedef NSUInteger NSKeyValueChange;

To access these attributes without invoking Notifications, we can use these functions: 
-primitiveValueForKey: and -setPrimitiveValue:forKey: