Re: NSKeyedArchiver not saving as binary data
Re: NSKeyedArchiver not saving as binary data
- Subject: Re: NSKeyedArchiver not saving as binary data
- From: Ali Ozer <email@hidden>
- Date: Thu, 8 Feb 2007 13:27:53 -0800
Are you sure this code is actually writing a new file for you? The
code you posted works fine for me on 10.4.8 and generates a binary file.
Ali
Begin forwarded message:
From: Matt R <email@hidden>
Date: February 8, 2007 11:24:08 AM PST
To: email@hidden
Subject: NSKeyedArchiver not saving as binary data
Perhaps i'm overlooking something obvious, as is usually the case,
but I
cannot get my instance of NSKeyedArchiver to save my files as
binary data. I
use setOutputFormat to set it to the binary option, and I've tried
the other
settings as well, and have also experimented with re-ordering the
code, but
in every case my data is written in a very verbose XML format, and
for a
number of reasons I need just the raw binary data written to the
file. Can
anyone see what I'm doing wrong here and enlighten me as to my
mistake? This
test code is straight from an example in the apple docs ('Archives and
Serializations Programming Guide for Cocoa'), and works fine and
saves the
proper data, but just in the wrong format.
any thoughts? thank you
-matt
NSMutableData *data;
NSKeyedArchiver *archiver;
BOOL result;
data = [NSMutableData data];
archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[archiver setOutputFormat:NSPropertyListBinaryFormat_v1_0];
[archiver encodeObject:myString forKey:@"stringA"];
[archiver encodeInt:variable1 forKey:@"integerA"];
[archiver encodeInt:variable1 forKey:@"integerB"];
[archiver finishEncoding];
result = [data writeToFile:filePath atomically:YES];
[archiver release];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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