• 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: Saving as xml
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving as xml


  • Subject: Re: Saving as xml
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 5 May 2008 10:55:36 -0700


On 5 May '08, at 10:45 AM, John Joyce wrote:

What's the best method to save a document as xml?
Should NSKeyedArchiver be doing this?
My document and its objects are very simple, they can easily be nothing more than BOOLs and NSStrings (as keys).

You can use either NSKeyedArchiver or NSPropertyListSerialization. The latter is simpler and produces more readable output, but only works on dictionaries/arrays/numbers/bools/dates/data.


Other issue:
If I have an NSDictionary (composed of two NSArrays' objects, keysArray, objectArray) that I want to use as a constant of sorts for all documents and controllers in a document-based app, is there a recommended way to declare the dictionary or a file it should go in?
Should it belong to my instance of NSApp to make it available to all objects in the app?

Put it in a property-list file (".plist") and add it to your Xcode project; it'll get copied into the app's Resources directory. You can then use NSBundle's resource methods to get the path given its name, and [[NSDictionary alloc] initWithContentsOfFile:] to read it. Then just put it in a global variable or make a class method that returns it.


—Jens

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

_______________________________________________

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Saving as xml
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Saving as xml (From: John Joyce <email@hidden>)

  • Prev by Date: Saving as xml
  • Next by Date: Re: Cocoa-dev Digest, Vol 5, Issue 730
  • Previous by thread: Saving as xml
  • Next by thread: Re: Saving as xml
  • Index(es):
    • Date
    • Thread