开发者

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

开发者 https://www.devze.com 2023-03-22 04:03 出处:网络
This is the hierarchy of my application, where i need to observe a property: ObjectA -----windowControllerA (NSWindowController)

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 se开发者_如何学编程nt to an object that is not KVC-compliant for the "content" property.

What i have to do to observe propertyX from ObjectA ?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号