• 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: Per-document preferences?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Per-document preferences?


  • Subject: Re: Per-document preferences?
  • From: SA Dev <email@hidden>
  • Date: Fri, 24 Jun 2005 20:33:56 -0400



On Jun 24, 2005, at 7:16 PM, James Bucanek wrote:

As I look at the problem, I think this is exactly what I'll do: Create an NSMutableDictionary and store all of the user settings and layout parameters. Using NSPropertyListSerialization, I shouldn't have any trouble turning a dictionary of document properties and user settings into an XML or binary file that I can store inside the package.


Okay, here's where you're missing the magic that is Cocoa. Check out NSDictionary's writeToFile:atomically: and its initWithContentsOfFile: methods. It saves the data in plist (XML) format.



What I'm dreading is having to save and restore the dozens of little layout variables for the window. It looked like the "autosave" feature of NSTableView, et. al. was designed to remove this burden from the programmer, but it seems hopelessly tied to the application defaults.


NSStringFromRect() and NSRectFromString() functions will make a string that can be stored in your dictionary and turn that string back into a rect (frame) for your window. For the rest, as long as you can create (and restore from) a type that can be stored in a dictionary (string, number, data), you're golden.




_______________________________________________
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


  • Follow-Ups:
    • Re: Per-document preferences?
      • From: James Bucanek <email@hidden>
References: 
 >Re: Per-document preferences? (From: James Bucanek <email@hidden>)

  • Prev by Date: nibtool output
  • Next by Date: Re: nibtool output
  • Previous by thread: Re: Per-document preferences?
  • Next by thread: Re: Per-document preferences?
  • Index(es):
    • Date
    • Thread