Re: NSKeyedUnarchiver questions
Re: NSKeyedUnarchiver questions
- Subject: Re: NSKeyedUnarchiver questions
- From: James Bucanek <email@hidden>
- Date: Wed, 10 May 2006 07:47:40 -0700
Scott Frankel wrote on Tuesday, May 9, 2006:
>
>I'm attempting to unarchive data my app has written to disk, but so
>far have not had any luck. It dies leaving a signal 10 error.
>
>The following snippet:
>
> NSMutableArray *newArray;
> newArray = [NSKeyedUnarchiver unarchiveObjectWithFile:@"/absolute/
>path/to/theFile.plist"];
>
>yields newArray with zero content member items, as shown in the
>debugger. Zilch.
>
>Using NSFileManager methods, I confirm what an `ls -l` in the
>terminal shows, that the file both exists and is readable. Using
>`cat` in the terminal shows that the file contains what I believe is
>valid data. (I archive it as human-readable ASCII characters using
>[archiver setOutputFormat:NSPropertyListXMLFormat_v1_0];)
Two things to try:
- Use the basic +[NSKeyedArchiver archiveRootObject:toFile:] to write the NSArray to the file in the default binary format; then try to see if you can read that back in. If that works, then something's hosed with how your are overridding the format.
- Check the logs for exceptions thrown during archiving or unarchiving. Attach a delegate to the NSKeyedUnarchiver and see if it throws any of the exception messsages (specifically unarchiver:cannotDecodeObjectOfClassName:originalClasses:).
>Also, in reading the doc (above), I note 2 methods:
>unarchiveObjectWithData and unarchiveObjectWithFile. What does it
>mean to encode an object graph "in data," rather than "to a file?"
One method writes the serialized data to a file. The other serializes the data and writes it to an memory block and returns the serialized data as an NSData object: i.e. fprintf vs. sprintf
--
James Bucanek
_______________________________________________
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