How is notify used in Cocoa?

Is there an example of how to use notify in Cocoa? The documentation on the RemObjects site still says it’s a .NET-only feature, but that’s no longer true as of 7.0. This is the kind of thing that drives me NUTS about trying to get up to speed in Oxygene.

Agreed, we need to get the docs updated on that.Essentially, notify will integrate with Cocoa’s KVO. here’s the raw info that will eventually make it into docs:

Documentation

Echoes

INotifyPropertyChanging is implemented (if the mscorlib has it)
and INotifyPropertyChanged is implemented. If the base type already implements it it expects there to be a “raise” to the property for PropertyChanged/PropertyChanging (else it fails).

Nougat

Notify works by A: Ignoring if it’s there unless it has a name (because the framework handles that case automatically via KVO), then it implements the automaticallyNotifiesObserversForKey, returns false for the values with a special notify value, otherwise returns the inherited value. For each property with a notify with name, it writes a willChangeValueForKey before, didChangeValueForKey after (only if the value did change)

Cooper

There’s no special interface in Cooper for this, instead it’s a pattern:

   private java.beans.PropertyChangeSupport changes := new java.beans.PropertyChangeSupport(this);
 
   protected void firePropertyChange(string name, object old, object new) 
   {
      changeSupport.firePropertyChange(name, old, new);
   }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changes.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changes.removePropertyChangeListener(listener); 
    }

    public void setSampleProperty(String value) {
        String oldValue = sampleProperty;
        sampleProperty = value;
        firePropertyChangeListener("sampleproperty", oldValue, sampleProperty);
    }

When the base class has the add/remove it will expect a protected fire to exist, else it will fail.

Thanks, Marc. As much as it pains me to be critical, for most users “if it’s not documented, it doesn’t exist yet.”

Yeah, hear ya.