Understanding KVO in iOS

Forrest picture Forrest · Jan 27, 2011 · Viewed 13.4k times · Source

Regarding "Ensuring KVO Compliance", there are some official definition which seem like hard to understand

In order to be considered KVO-compliant for a specific property, a class must ensure the following;

  1. The class must be key-value coding compliant for the property as specified in Ensuring KVC Compliance.

  2. The class must allow automatic observer notifications for the property, or implement manual key-value observing for the property.

Who can give more specific examples to make this more clear ? Thanks

Answer

Benedict Cohen picture Benedict Cohen · Jan 27, 2011

Take a look at Ensuring KVO Compliance the Automatic Versus Manual Support section of the Key-Value Observing Programming Guide. Compliance is essentially achieved by following naming conventions for methods and/or ivars.

In my experience KVO tends to 'just work', which is nice.