Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:58:47+00:00 2026-05-28T02:58:47+00:00

I have a NSViewController subclass with a convenience method to return the window controller

  • 0

I have a NSViewController subclass with a convenience method to return the window controller like this

@interface ILViewController : NSViewController

- (ILWindowController *)windowController;

@end

@implementation ILViewController

- (NSWindowController *)windowController {
    return self.view.window.windowController;
}

- (void)setView:(NSView *)view {
    [self willChangeValueForKey:@"windowController"];
    [super setView:view];
    [self didChangeValueForKey:@"windowController"];
}

@end

The window controller has a NSString * property named mainStatus which I’m trying to bind to through the view controller. However, I am getting this error at run time.

Cannot update for observer <NSAutounbinderObservance 0x1005cf990> for the key path 
"windowController.mainStatus" from <ILViewController 0x1001976b0>, most likely because
the value for the key "windowController" has changed without an appropriate KVO
notification being sent. Check the KVO-compliance of the ILViewController class.

Why is this happening? I have appropriately sent the KVO notifications.

The following code, which uses an ivar and is actually NOT KVO compliant turns out to NOT result in any error….

@interface ILViewController : NSViewController {
    ILWindowController *_windowController;
}

- (ILWindowController *)windowController;

@end

@implementation ILViewController

- (NSWindowController *)windowController {
    return _windowController;
}

- (void)setView:(NSView *)view {
    [super setView:view];
    _windowController = view.window.windowController;
}

@end

This is confusing the heck out of me… Can someone see why the first implementation is not KVO compliant?

EDIT

Got it, if the view is added to window after it is set for the ViewController then the view’s window is indeed changed without appropriate KVO notification. However, when I try to observe the view’s window’s window controller, I’m getting errors like this

KVO autonotifying only supports -set<Key>: methods that return void. Autonotifying 
will not be done for invocations of -[NSView _setWindow:].
Cannot remove an observer <NSKeyValueObservance 0x102e17880> for the key path
"window.windowController.mainStatus" from <NSView 0x102e13ec0>, most likely because
the value for the key "window" has changed without an appropriate KVO notification
 being sent. Check the KVO-compliance of the NSView class.

So if you can’t observe a view’s window, surely there’s gotta be some way to be notified when the view’s window changes. Does anyone know how?

Also, these still doesn’t explain why the second version of the code that uses an iVar without KVO notification actually work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:58:48+00:00Added an answer on May 28, 2026 at 2:58 am

    If you set the view, and then add the view to a window, then windowController will have changed without KVO notifications being sent out. You need to observer your own view’s window and send out will/did change notifications when that changes (It’s possible the automatic key path dependence stuff does this for you, I don’t remember if it actually works with paths or just values). Similarly if the window’s windowController changes then you’ll have the same problem.

    Edit: The method is called -automaticallyNotifiesObserversForKey:. I’m inclined to say that it doesn’t support key paths, so you’ll have to do the manual observing/notifying yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In AppKit we have representedObject available through NSViewController , this representedObject is generally set
I have a main window controller which is a NSWindowController (golden rectangle) with a
in my app i have an UITabBarController with UINavigationControllers initialized like this UINavigationController *newsNavigationController
I have a property that looks like this: @property (weak, nonatomic) id<NavigationControllerDelegate> delegate; But
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have the following class hierarchy: NSViewController MyGeneralViewController ViewControllerA ViewControllerB MyGeneralViewController holds some common
How to access navigation controller from the AppDelegate? Suppose I have the following viewControllers:
I'm just wondering why when I create a new view controller, I have to
I have a NSTabView, where I alloc and load the same NSViewController on its
Have not done this before, so obviously I suck at it. Here 64 pixels

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.