NSNotification is your friend. 

When your custom views do something notable, they should post or enqueue an 
NSNotification containing the relevant info. Presumably you will have 
subscribed your NSDocument to those notifications in your override of 
-windowControllerDidLoadNib. 

This way the views don't need to know anything about the document, and the 
document doesn't really need to know anything about the views. It just has to 
"answer the mail".

Put the notification name definitions in a separate file, that both can #import.

You can eliminate the custom view IBOutlets in your NSDocument object by using 
the same tactic in reverse.

If a communication doesn't need to be synchronous, use enqueued notifications 
with "post when idle" to keep your main thread lively and responsive. 

Remember that the notification object doesn't have to be the sender, it can 
even be nil if you just don't care at all (a global notification). It can also 
be a reference to the document's NSWindow or the document itself, since every 
view knows its parent [[window windowController] document]. This is handy in 
the document pattern. _______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to