NSKeyedArchiever and XML Format

2008-12-11 Thread Patrick Mau
Good morning For the last day I have pulled my hair over NSKeyedArchiever and friends to load and save small data objects. I mainly use this feature for debugging, so the output format is set to XML. Normally, one would write an object 'p' in binary format, using: [NSKeyedArchiver

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Martin Wierschin
Hi Patrick, The property list editor shows the root object key as Root, but in fact the key is saved as 'root'. I was unable to unarchieve my objects using 'unarchiveObjectWithFile' until I finally created a hex-dump and figured out that the only difference between the files was 'root'

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Nathan Vander Wilt
On Dec 11, 2008, at 1:01 AM, Patrick Mau wrote: Good morning For the last day I have pulled my hair over NSKeyedArchiever and friends to load and save small data objects. I mainly use this feature for debugging, so the output format is set to XML. Normally, one would write an object 'p'

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Nathan Vander Wilt
On Dec 11, 2008, at 5:34 PM, Martin Wierschin wrote: [a encodeObject:p forKey:@root]; Does using: [a encodeRootObject:p]; instead of the line above make it work as expected? A good idea, but IIRC that did not work. In fact, I think it produced an archive that silently failed to be read

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Martin Wierschin
[a encodeObject:p forKey:@root]; Does using: [a encodeRootObject:p]; instead of the line above make it work as expected? A good idea, but IIRC that did not work. In fact, I think it produced an archive that silently failed to be read back by the stock +[NSKeyedUnarchiver

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Graham Cox
On 12 Dec 2008, at 1:32 pm, Martin Wierschin wrote: The problem I had was that I needed to use -[NSUnarchiver decodeClassName:asClassName:] for unarchiving a file previously encoded using the convenience method. Certainly it's possible to use the class method +[NSUnarchiver

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Martin Wierschin
The problem I had was that I needed to use -[NSUnarchiver decodeClassName:asClassName:] for unarchiving a file previously encoded using the convenience method. Certainly it's possible to use the class method +[NSUnarchiver decodeClassName:asClassName:], but it seems silly to pollute the

Re: NSKeyedArchiever and XML Format

2008-12-11 Thread Graham Cox
On 12 Dec 2008, at 2:19 pm, Martin Wierschin wrote: That actually would not have helped, because it's an instance method. The whole problem to begin with was that there wasn't any clear way for a manually constructed instance of NSKeyedUnarchiver to decode a file previously saved using