Getting modified object in observeValueForKeyPath:ofObject:change:context: for non-simple key paths

  • Hi all,

    I'd like to get notifications when a particular property of any object
    in a to-many relationship changes. Right now, I do that by observing
    the key path "arrangedObjects.serviceURL" on an NSArrayController.
    This does indeed notify me when any of the serviceURL properties
    change. However, I can't seem to figure out how to get the specific
    object in the array whose property was changed from the arguments
    passed in observeValueForKeyPath:...

    I did manage to get the object by going directly to the
    NSArrayController and asking it for its selection, but it seems a bit
    hackish to do so (i.e., does Cocoa guaranteed that the selection will
    always be set correctly when observeValueForKeyPath:... is called?)

    Is there a proper work-around pattern for this?

    Another related question, what if I'm binding to an object that
    doesn't have a concept of selection? For example, if I wanted to bind
    to NSManagedContext's -registeredObjects (I actually haven't tried
    this yet, but will in a moment).

    Thanks,

    Mike
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today