key-value-observing

Key Value Observing with an NSArray

I've looked on SO for examples of using Key Value Observing with an NSArray (or NSMutableArray) and apparently you need to use an NSArrayController (which unlike KVO I'm not familiar with), but I haven't found concrete examples of how to do this... can anyone explain with some sample code? For instance, if I have a GameModel which repre...

Preventing re-entering observeValueForKeypath recursively when KVO fired from model setter

I have a whole host of models that watch themselves for changes. When a setter is triggered, the observer in the model is called and within that model I make a call to a web server and update information in the web server so it correctly has the data it should. However, in my call to the web server I can get back an error for anything f...

KVC array: getters vs indexed accessors?

I'm confused by this: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB Supposing @interface Office : NSObject { NSMutableArray *employees; } What is the benefit of implementing the collection accessors? How is [anOffi...

Why does NSOperation disable automatic key-value observing?

When working with a custom NSOperation subclass I noticed that the automatic key-value observing is disabled by the [NSOperation automaticallyNotifiesObserversForKey] class method (which returns NO at least for some key paths). Because of that the code inside of NSOperation subclasses is littered by manual calls to willChangeValueForKey:...

Prime examples of data-binding

I am implementing a barebones framework in JavaScript that just provides data-binding between objects. The data-binding can either be one-way or two-way, and potentially have multiple objects bound on some property. There are several data-binding solutions available for various languages and I am trying to get a good idea of the best of ...

Is it possible to bind to a property of an NSArrayController?

Basically in IB where there are the options "arrangedObjects", "selection" etc in the "Controller Key" drop down, is it possible to create my own entry in there to bind to? If possible this would allow me to bind certain text boxes to filtered aspects of the array held by the ArrayController (and furthermore use operators like @count on...

When manually triggering a KVO event, can the change dictionary be amended?

I have a data model, composed mostly of an NSMutableArray 'contents' and NSMutableDictionary 'contentsByName'. I have ViewController objects that I wish to observe changes in the data model. I have a property "count" on the model that returns the size of the array 'contents' and I can trigger a KVO change observation with willChange: an...

iPhone MKMapView annotations observers selectable once

Hi, I have different custom map annotations on my MKMapView, and when creating the custom view I add an observer and disable the default popup. At the top of MapViewController.m: static NSString* const ANNOTATION_SELECTED_DESELECTED = @"annotationSelectedOrDeselected"; - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotat...

Why use TT_RELEASE_SAFELY in three20 for iPhone?

#define TT_RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; } Why is does three20 consider it safe to assign an ivar to nil after releasing it? Is it unsafe to leave out the ivar = nil step? This is all I found: http://github.com/facebook/three20/commit/1b946f475fb28d60e0aafc9ef394050c642c3a5b#commitcomment-115517 I ...

Observing the editing property of a UITableViewController

Why can't I observe the editing property of an instance of UITableViewController? I'm using the following code: [self addObserver:self forKeyPath:@"editing" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL]; And have implemented the method: - (void)observeValueForKeyPath...