FROM : Will Mason
DATE : Wed Nov 17 19:49:23 2004
I'm confused about proper usage of NSCoder. Here's the problem. I want
to encode/decode an array of "unsigned long" values. The problem is
that I can't make identical keyed and unkeyed archives. For example, to
encode the array to an unkeyed archive I just call [NSCoder
encodeArrayOfObjCType: @encode(unsigned long) count: numberOfWords at:
&myArray]. Easy enough.
However, to put the array into a keyed archive my only choice really
(without creating a new key for every element of the array) is [NSCoder
encodeBytes: &myArray length: sizeof(unsigned long) * numberOfWords
forKey: @"words"]. This hardly works, as now I cannot decode the array
on a machine of different endianness. For example, if I want to read
the archive on an i386 Linux box running GNUstep, I'm stuck, as the
values of the array will all have the wrong endianness.
In neither case can I read the archive on a machine that has a
differently sized "unsigned long" than the machine that writes the
archive.
Does anyone know how to create an archive that doesn't leave me hanging
in terms of endianness?
Thanks for any help,
Will
DATE : Wed Nov 17 19:49:23 2004
I'm confused about proper usage of NSCoder. Here's the problem. I want
to encode/decode an array of "unsigned long" values. The problem is
that I can't make identical keyed and unkeyed archives. For example, to
encode the array to an unkeyed archive I just call [NSCoder
encodeArrayOfObjCType: @encode(unsigned long) count: numberOfWords at:
&myArray]. Easy enough.
However, to put the array into a keyed archive my only choice really
(without creating a new key for every element of the array) is [NSCoder
encodeBytes: &myArray length: sizeof(unsigned long) * numberOfWords
forKey: @"words"]. This hardly works, as now I cannot decode the array
on a machine of different endianness. For example, if I want to read
the archive on an i386 Linux box running GNUstep, I'm stuck, as the
values of the array will all have the wrong endianness.
In neither case can I read the archive on a machine that has a
differently sized "unsigned long" than the machine that writes the
archive.
Does anyone know how to create an archive that doesn't leave me hanging
in terms of endianness?
Thanks for any help,
Will
| Related mails | Author | Date |
|---|---|---|
| Will Mason | Nov 17, 19:49 | |
| Daniel DeCovnick | Nov 18, 07:39 |






Cocoa mail archive

