How reliable is KVO with UIKit

UIKit is mostly NOT KVO compliant. This is mostly because UIView acts as high-level wrapper for CALayer, so when you eg. change the frame property of an UIView, it will change the layers frame but leave eg. the bounds property of the UIView untouched, so no observer will be triggered for the view.bounds path, because … Read more

Observing an NSMutableArray for insertion/removal

But shouldn’t the synthesized accessors automatically return such a proxy object? No. What’s the proper way to work around this–should I write a custom accessor that just invokes [super mutableArrayValueForKey…]? No. Implement the array accessors. When you call these, KVO will post the appropriate notifications automatically. So all you have to do is: [myObject insertObject:newObject … Read more

How can I do Key Value Observing and get a KVO callback on a UIView’s frame?

There are usually notifications or other observable events where KVO isn’t supported. Even though the docs says ‘no’, it is ostensibly safe to observe the CALayer backing the UIView. Observing the CALayer works in practice because of its extensive use of KVO and proper accessors (instead of ivar manipulation). It’s not guaranteed to work going … Read more