• 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
Re: Controller layer & document architecture
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Controller layer & document architecture


  • Subject: Re: Controller layer & document architecture
  • From: Shaun Wexler <email@hidden>
  • Date: Wed, 23 Jun 2004 12:11:31 -0700

On Jun 23, 2004, at 10:44 AM, Ken Tabb wrote:

So if I bind to a method in my app delegate which returns [[NSDocumentController sharedDocumentController] currentDocument], would my controller automagically update the info window's contents each time a different document window becomes main? Having read the currency converter bindings tutorial I'm a bit concerned about the bi-directional synching of info... is there a risk that the controller might update the wrong model with the view info, or vice versa, during the time when a different document window is becoming frontmost?

In your inspector panel's -init method, add:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeMain) name:NSWindowDidBecomeMainNotification object:nil];

And add these two methods:

- (void)windowDidBecomeMain:(NSNotification *)notification
{
NSWindow *window = [notification object];
NSDocument *document = [[NSDocumentController sharedDocumentController] documentForWindow:window];

if (document != currentDocument) {
[self willChangeValueForKey:@"document"];
[currentDocument release];
currentDocument = [document retain];
[self didChangeValueForKey:@"document"];
}
}

- (NSDocument *)document
{
return currentDocument;
}

Also if there is no currentDocument (eg. all document windows are closed) will that wreck the binding? I'm guessing my app delegate method would return nil, but how would the controller know to display "no document open" or "no object selected" or some such (like IB's inspector panel does).

There are default IB placeholders for NULL bindings...
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Controller layer & document architecture (From: Ken Tabb <email@hidden>)
 >Re: Controller layer & document architecture (From: Ken Tabb <email@hidden>)

  • Prev by Date: Re: bundlePath, FSPathMakeRef and FSGetCatalogInfo alias error
  • Next by Date: Fwd: Controller layer & document architecture
  • Previous by thread: Re: Controller layer & document architecture
  • Next by thread: Fwd: Controller layer & document architecture
  • Index(es):
    • Date
    • Thread