Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
I have a tableView in a kind of inspector window, and I want its delegate and dataSource to always be the current document.

I looked at the documentation, and saw no delegate methods for this. I also tried registering for a Key-Value change of current document like this:

Code:
[[NSDocumentController sharedDocumentController] addObserver:self  forKeyPath:@"currentDocument"  options:NSKeyValueObservingOptionNew  context:nil];
but it didn't work.

Any suggestions?
 

jamawa

macrumors newbie
Jul 7, 2009
10
0
Have a look at the windowDidBecomeMain: and windowDidResignMain: delegates from NSWindow. You can use these from within your document to update the inspector.

It is what I use to update my document-inspectors and it works nice and neat. There may be other methods as well though.

Cheers,
Jan Martin
 

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
Thanks .. I tried it before, but I tried again because of your advice. Turns out I forgot to specify the name when I added the observer.
:D

Works like a charm!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.