• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Manual KVO quirks with NSDocument and NSWindowController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Manual KVO quirks with NSDocument and NSWindowController


  • Subject: Manual KVO quirks with NSDocument and NSWindowController
  • From: Andrew White <email@hidden>
  • Date: Mon, 23 May 2005 22:50:29 +1000


I've set up my NSWindowController so that it observes a data member of its NSDocument and updates accordingly.


- (void) awakeFromNib
{
	...
	[[self document] addObserver: self
		forKeyPath: @"interestingData"
		options: nil context: nil
	];
}


interestingData is also the name of a method in the document. There is a also private method that looks like:


- (void) setInterestingData: (NSArray *) someData
{
	[self willChangeValueForKey: @"interestingData"];
	[_interestingData setArray: someData];
	[self didChangeValueForKey: @"interestingData"];
}


I have two quirks, however.


The first is that the window controller's version of observeValueForKeyPath:ofObject:change:context: is called twice during the call to [self didChangeValueForKey: @"interestingData"]. This doesn't break the app, but is an interesting feature.



The second is that when I close the window (and thus the document) I get an error:


2005-05-23 22:33:40.770 ProgramName[3584] An instance 0x118dc50 of class MyDocument is being deallocated while key value observers are still registered with it. Break on _NSKVODeallocateLog to start debugging.

According to the debugger, "close" is called for DeviceConfigDoc but "dealloc" is not. I did have code in MyWindowController to stop observing when the window controller's dealloc was called, but it doesn't seem to be called. I searched for a NSWindowController documentWillClose message, but there doesn't seem to be one. Nor can I find a "windowDidClose" notification - the closest I found was "close", and that doesn't seem to be called either when I click the close box.

Any ideas?

--
Andrew White

--------------------------------------------------------------------------
This email and any attachments may be confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Manual KVO quirks with NSDocument and NSWindowController
      • From: Tim Lucas <email@hidden>
    • Re: Manual KVO quirks with NSDocument and NSWindowController
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Printing my document
  • Next by Date: Re: Manual KVO quirks with NSDocument and NSWindowController
  • Previous by thread: Re: Printing my document
  • Next by thread: Re: Manual KVO quirks with NSDocument and NSWindowController
  • Index(es):
    • Date
    • Thread