Re: NSKeyedArchiver and NSValue
Re: NSKeyedArchiver and NSValue
- Subject: Re: NSKeyedArchiver and NSValue
- From: Ambroise Confetti <email@hidden>
- Date: Mon, 27 Oct 2003 15:35:50 +0100
Le 27 oct. 03, ` 14:51, Jean Bovet a icrit :
Can someone confirm that NSKeyedArchived cannot encode struct ? If
that correct, how can I save struct when using an NSKeyedArchiver for
my other data ?
Apple probably removed that feature on purpose. Take a look at:
<file:///Developer/Documentation/Cocoa/Conceptual/Archiving/Tasks/
codingctypes.html#//apple_ref/doc/uid/20001294>
(The address may be only valid if you installed Xcode... Anyway, in the
Cocoa documentation, take a look at the topic "Archives and
Serialization" and its chapter named "Encoding and Decoding C Data
Types".)
The interesting part:
"You should not wrap a structure with an NSData object and archive
that. If the structure contains object or pointer fields, the data
object isnt going to archive them correctly. You also create a
dependence on how the compiler decides to lay out the structure, which
can change between versions of the compiler and may depend on other
factors. A compiler is not constrained to organize a structure just as
youve specified it in the source codethere may be arbitrary internal
and invisible padding bytes between fields in the structure, for
example, and the amount of these can change without notice and on
different platforms. In addition, any fields that are multiple bytes in
width arent going to get treated correctly with respect to endianness
issues. You will cause yourself all sorts of compatibility trouble."
Ambroise
http://www.cellulo.info/
_______________________________________________
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.