Storing NSColor & NSData objects in an XML document

  • Hi,

    I want to write out NSColor objects to XML. I know I can archive them
    into NSData objects, and a string representation from those. The
    string can then be added to the XML. What I have trouble with is
    getting the string back into an NSData object so that I can unarchive.
    Any pointers?

    António

    --------------------------------------------
    I try to take one day at a time, but sometimes, several days attack me
    all at once!
    --------------------------------------------
  • On 28 Nov 2007, at 11:56, Antonio Nunes wrote:

    > I want to write out NSColor objects to XML. I know I can archive
    > them into NSData objects, and a string representation from those.
    > The string can then be added to the XML. What I have trouble with is
    > getting the string back into an NSData object so that I can
    > unarchive. Any pointers?

    Ok, I might simply be less than smart here, and the answer is probably
    obvious, but I can't see it. The basic issue is: I have an NSData
    object and want to store it in an XML node, then later restore it from
    an XML node. Lots of sifting through documentation and usually helpful
    internet sites and generally making the cogs in my brain groan, squeak
    and creak for the better part of yesterday and today yielded no usable
    results.

    I know how to (un)archive NSData objects to/from disk and user
    defaults, but am not sure how to turn them into strings (to store in
    XML elements) and especially how to restore them from strings that
    represent NSData objects.

    Any help would be greatly appreciated.

    -António

    ----------------------------------------------------
    It is better to light a candle than to curse the darkness
    ----------------------------------------------------
  • Hmm, why not encode as Base64 and decode it later?

    :: marcelo.alves


    On Thursday, November 29, 2007, at 03:38PM, "Antonio Nunes" <devlists...> wrote:
    > On 28 Nov 2007, at 11:56, Antonio Nunes wrote:
    >
    >> I want to write out NSColor objects to XML. I know I can archive
    >> them into NSData objects, and a string representation from those.
    >> The string can then be added to the XML. What I have trouble with is
    >> getting the string back into an NSData object so that I can
    >> unarchive. Any pointers?
    >
    > Ok, I might simply be less than smart here, and the answer is probably
    > obvious, but I can't see it. The basic issue is: I have an NSData
    > object and want to store it in an XML node, then later restore it from
    > an XML node. Lots of sifting through documentation and usually helpful
    > internet sites and generally making the cogs in my brain groan, squeak
    > and creak for the better part of yesterday and today yielded no usable
    > results.
    >
    > I know how to (un)archive NSData objects to/from disk and user
    > defaults, but am not sure how to turn them into strings (to store in
    > XML elements) and especially how to restore them from strings that
    > represent NSData objects.
    >
    > Any help would be greatly appreciated.
    >
    > -António
    >
    > ----------------------------------------------------
    > It is better to light a candle than to curse the darkness
    > ----------------------------------------------------
    >
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today