Re: encoding structs (NSCoder / NSArchiver issue)
Re: encoding structs (NSCoder / NSArchiver issue)
- Subject: Re: encoding structs (NSCoder / NSArchiver issue)
- From: Chris Ridd <email@hidden>
- Date: Mon, 19 Jan 2004 09:30:45 +0000
On 19/1/04 6:01 am, Justin Anderson <email@hidden> wrote:
>
Those are of static size and don't contain pointers, so they should get
>
allocated in contiguous blocks. I *think* it's just a matter of typing
>
[NSData dataWithBytes:aPlaneStruct length:sizeof(planeStruct)] for each
>
planeStruct.
Doing that will make you very vulnerable to changes in the way your compiler
lays out your structure in memory. Change to a different compiler (version),
or a 64-bit compiler with different alignment requirements, or for a
different CPU architecture and *whammo* :-(
The Cocoaish answer would presumably be to use NSCoder/NSEncoder or
NSKeyedArchiver/NSKeyedUnarchiver to handle each separate field (including
array elements) of the struct.
Cheers,
Chris
_______________________________________________
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.