Re: Archiving and Dearchiving
Re: Archiving and Dearchiving
- Subject: Re: Archiving and Dearchiving
- From: Marco Binder <email@hidden>
- Date: Fri, 28 Mar 2003 10:49:29 +0100
[archiver encodeRootObject:_myRootObect forKey:@"RootObject"];
Where does this method come from? I can not find it... And it doesnt
make too much sense to me: why would you want a key for a root object?!
It will be the only object encoded in an archiver. Either use a plain
NSArchiver and call encodeRootObject:... on it, or use an
NSKeyedArchiver to encode any number of objects and associate them with
keys via encodeObject:... forKey:...
to decode it I used:
_myRootObject = [NSKeyedUnarchiver
unarchiveObjectWithFile:@"archive.xml"];
after this line _myRootObject is nil.
I dont know what the exact problem is. Try reading into an NSData
object and then use [[NSUnarchiver alloc] initForReadingWithData:....]
and then call _myRootObject = [[unarchiver decodeObject] retain].
You should really look into the keyed archiving and unarchiving
stuff... if your app's file-format changes, your still on the save side
with keyes archiving. Have your read Bill's article? You should...
Marco
PS: If you dont want to use the NSData stuff, try [NSArchiver
archiveRootObject:... toFile:...] and [NSUnarchiver
unarchiveObjectWithFile:...]
--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.