• 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: [newbie] Window state saving
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] Window state saving


  • Subject: Re: [newbie] Window state saving
  • From: j o a r <email@hidden>
  • Date: Sun, 15 Jan 2006 01:26:04 +0100


On 15 jan 2006, at 00.42, Jonathan Saggau wrote:

I'm working on a very small NSDocument app that needs to reload the state of
all GUI widgets on the NSDocument's main window when loading a document.

When you say state, what do you mean? The obvious thing would be that you mean that the user interface controls must have the settings / contents that matches the data in the document - I will go with the assumption that this is what you're talking about.


Right now (and it does work) I'm enumerating the widgets (Sliders and
buttons and things) and putting the state info in a plist and refreshing the
view from the plist on open. I wonder if there is a more elegant way to do
this.

In the traditional Cocoa design, it would be up to the window controller to do this tedious work when the document is loaded, and to ensure that it's kept up to date as the user makes modifications. Nowadays it's perhaps best done using Cocoa bindings. Bindings makes this all automatic. There's a lot of documentation and sample code on that topic - go check it out!


Perhaps Serializing the whole mess to disk with a coder? I know the
NIB files do this kind of thing "freeze-drying" the GUI as it were for a
given app. I just wonder if I'm missing a method that says "save state of
entire window to disk." :)

Note that the controls in the UI should only ever reflect the true state of your document data, that should reside in the document. So, saving the document would in effect also enable you to restore the state of the user interface.


j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >[newbie] Window state saving (From: Jonathan Saggau <email@hidden>)

  • Prev by Date: Seemingly bizzare calling of method
  • Next by Date: Re: Seemingly bizzare calling of method
  • Previous by thread: Re: [newbie] Window state saving
  • Next by thread: Seemingly bizzare calling of method
  • Index(es):
    • Date
    • Thread