• 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: NSUnarchiver and StickiesDatabase
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUnarchiver and StickiesDatabase


  • Subject: Re: NSUnarchiver and StickiesDatabase
  • From: glenn andreas <email@hidden>
  • Date: Thu, 13 Jan 2005 09:18:13 -0600


On Jan 12, 2005, at 10:11 PM, Matthew wrote:

Has anyone had any luck loading the ~/Library/StickiesDatabase file using an NSUnarchiver?
[snip]
After a long, long time working on this, I am unable to get it to load using the basic approaches such as unarchiveObjectWithFile and decodeValueOfObjCType.

It doesn't seem that this should be quite as difficult as I'm making it, so I have to ask if there's a detail I'm overlooking. If the Document class is defined with the correct data instances, shouldn't a simple call to unarchiveObjectWithFile work?

No, not necessarily. (and obviously this is the case).

If this is the case, then can you think of any gotcha's on a task like this?


NSArchiver can store pretty much anything in arbitrary ways - it doesn't keep track of the types of things encoded with encodeValueOfObjCType (which is why you crash real bad if your encoding and decoding aren't exactly matched, and why keyed archiving is the better general solution)


Another way to ask this might be "if you were given an file encoded with NSArchiver without any details about its contents other than an interface file outlining its data instances, how would you unarchive it?"


As mentioned above, you don't know exactly what order/format things are stored in with an NSArchiver - there is little in the resulting format that provides that information (things which are encoded as objects have a bit more context, since they need to encode what class they belong to, which is stored as a string, and obviously string data is easily visible).


Personally, I'd got the other way - make a simple sample document containing as little information as possible, and then try to write a program that produced the same file, and compare the results to see where they differ and keep adjusting that second program until they match. At that point, you know how it is encoded, so you can write the decoder.


Glenn Andreas                      email@hidden  <http://www.gandreas.com/> oh my! Mad, Bad, and Dangerous to Know

_______________________________________________
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: 
 >NSUnarchiver and StickiesDatabase (From: Matthew <email@hidden>)

  • Prev by Date: Re: NSTextView Line Number
  • Next by Date: [SOLVED] Re: waitForDataInBackgroundAndNotify blocking
  • Previous by thread: NSUnarchiver and StickiesDatabase
  • Next by thread: Keynote (the Application, not the Event)
  • Index(es):
    • Date
    • Thread