Search code examples
objective-ccocoakey-value-observing

Observe property of a custom view from Window Controller in Cocoa KVO


This is the hierarchy of my application, where i need to observe a property:

ObjectA
   |
   |-----windowControllerA (NSWindowController)
              |
              |-------Content(NSWindow)
                          |
                          |--------contentView (Custom NSView)
                                         |
                                         |---- propertyX (property to observe)

I try to observe from ObjectA with this code: [self.windowControllerA addObserver:self forKeyPath:@"self.content.contentView.property" options:NSKeyValueObservingOptionOld context:@"context"];

But it doesn't work, i get this error : was sent to an object that is not KVC-compliant for the "content" property.

What i have to do to observe propertyX from ObjectA ?


Solution

  • I found the problem! this's the right path "window.contentView.property"