Re: NSKeyedArchiver: confusion
Re: NSKeyedArchiver: confusion
- Subject: Re: NSKeyedArchiver: confusion
- From: Jeff Kelley <email@hidden>
- Date: Tue, 18 May 2010 17:28:41 -0400
Right, but in your original e-mail, you said, "When I open the file the old junk is all there."
If you want the data to be in the file then you'll need to save it to the file. When you create the NSMutableData object, it's copied out of the file and into memory; you are not operating directly on the file.
What happens if you create a keyed unarchiver immediately after the code you sent us and unarchive the object in question?
Jeff Kelley
University of Michigan
On May 18, 2010, at 5:21 PM, Matthew Weinstein wrote:
> My mistake for not being clear:
> I have an NSData in an object;
> I read that data using a keyedArchiver to get to the chunk I want.
>
> I want to replace a chunk of that data with another using the same key. (the file part is immaterial).
>
>
> On May 18, 2010, at 2:10 PM, Jens Alfke wrote:
>
>>
>> On May 18, 2010, at 1:40 PM, Matthew Weinstein wrote:
>>
>>> The problem: The old @"codedDataArray" is not replaced! When I open the file the old junk is all there. The old array is not discarded and replaced with the new (myRecs) array. So I cannot use NSKeyedArchiver like an NSMutableDictionary?
>>
>> I’m not sure I understand. Were you expecting the code you posted to write to the file? But nowhere in that code did you specify what file to write to. Archivers don’t directly know about files; they work on in-memory data. (Yes, there are convenience class methods for reading and writing a file, but they just call NSData methods to transfer the data to/from a file.)
>>
>> It sounds like what you want to do is call [NSKeyedArchiver archiveRootObject: obj toFile: file].
>>
>> —Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden