CocoaDev

Edit AllPages

With the term “inspector panel/palette” i mean singleton NSPanel window with it’s NSWindowController, Nib, what is used represent some aspects of active NSSDocument subclass or just the window as seen in Photoshop (for example layers panel), Pages (Inspector) and so on. To create that shiny, shaddow casting panel, use the same technique as for other singleton windows+controller+nib packs (think “Preferences…” window).

Here I’ll try to describe how i set up synchronizing the document window with inspector panel.

So, I assume you have

1) add something along those lines in MyDocument’s NSWindow’s delegate:

This will send notifications whenever window becomes main and closes. Those notifications the Inspector will observe.

2) somewhere in inspector’s NSWindowController’s init method add observers to notifications:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentDidChange:) name:MyDocumentDidChangeNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentWillChange:) name:MyDocumentWillChangeNotification object:nil];

and notification callbacks:

Some more info MakingNibsTalkToEachOther, HasPantherChangedHowToDoNibs

– ArnisVuskans