• 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: Design Principles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Principles


  • Subject: Re: Design Principles
  • From: Pandaa <email@hidden>
  • Date: Fri, 23 Jul 2004 23:04:51 +0200

2004-07-23 kl. 22.03 skrev Albion Baucom:

Im still very new to Cocoa/Objective-C programming and IB UI design, so
bare with me on these questions ...

I have a document based application that I have added a preferences panel
to. I want to "broadcast" those preferences alternately to either a single
open document (the "key" window), or to all currently open documents.

If you want a mechanism of having the preference change be applied alternatively to *one* document *or* to all documents, I would suggest separating the preferences for which that makes sense from the general preferences and show them in a sheet for every document instead of introducing a concept of scope to your preference panel.

I am a little cornfused on how I should implement this.

I have subclassed NSDocuments that manage an NSWindow that has a
customview.

I have a Preferences NSObject that simply stores the preferences.

Is there a special reason you are not using NSUserDefaults to store your preferences? If not, I suggest storing your preferences directly in the NSUserDefaults standardUserDefaults. That way you won't need your Preferences object, and any object that needs to read preference settings can do so easily.

I have a
PreferencesController NSWindowController that manages the actual
preferences UI panel and provides the outlets for the widgets.
PreferencesController is the File Owner in my Preferences NIB.

I want the preferences UI to talk to the customview in my subclassed
NSDocument.

If it only needs to talk to the customview to broadcast preference changes, use notifications.

Should the PreferencesController manage this? It seems as though it
should. That keeps the Preferences NSObject as generic as possible; all it
does is store and provide the actual preference values and does not need
to know about the views that are actually using the preferences. The
PreferencesController then manages the user input of new preferences and
the broadcast of the preference values to all the currently open
documents. It basically sits between, and links, the preferences values
and the documents.

If PreferencesController is indeed the corret way to implement these
actions, how do I go about getting a handle on the customviews in the
PreferencesController so I can pass the preferences?

It is probably more elegant to use notifications. Let your preference GUI send notifications when a preference is changed, and have any object in your application that is affected by the preference register for said notifications.

This keeps your PreferenceController separated from the rest of your application, and also avoids descending the view hierarchies which is potentially inefficient. Also, generally there's no reason to believe that all objects affected by preference changes will be views in an open window so having your preference controller seek out every affected object promises to become quite an interesting game of hide-and-seek.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. email@hidden . . www.synapticpulse.net .
_______________________________________________
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.


  • Follow-Ups:
    • Re: Design Principles
      • From: Albion Baucom <email@hidden>
References: 
 >Design Principles (From: Albion Baucom <email@hidden>)

  • Prev by Date: Re: Bug in NSImageView?
  • Next by Date: Re: AirTunes Details
  • Previous by thread: Design Principles
  • Next by thread: Re: Design Principles
  • Index(es):
    • Date
    • Thread