Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best practice for multiple NSWindowControllers on a document?



Well, I have this type of architecture, but my documents are immutable.

That said, it would appear to me that since you **know** all the controllers, you could send each a message saying the document changed, and let them deal with it, e.g. documentUpdated.

Since they are in an array you can use one of those makeObjectsPerformSelector methods of NSArray to efficiently send this to each window controller. (You can also roll your own specialized versions of makeObjectsPerformSelector and add them as a category - several examples of this on the web).

You could get more detailed with different messages conveying different change notifications, ie setDocumentTextUpdatedInRange:SomeRange, etc.

My suggestion is to avoid bindings and notifications, since the target of the messages, that is the array of windowControllers, is always known and in fact a property of your NSDocument subclass.

Just my $0.02.

David
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.