Re: encoding structs (NSCoder / NSArchiver issue)
Re: encoding structs (NSCoder / NSArchiver issue)
- Subject: Re: encoding structs (NSCoder / NSArchiver issue)
- From: "M. Uli Kusterer" <email@hidden>
- Date: Mon, 19 Jan 2004 13:28:38 +0100
At 1:01 Uhr -0500 19.01.2004, Justin Anderson 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.
And if your array of structs isn't malloc'd in pieces, you could
grab each array at once instead of individually.
Wouldn't that cause problems with alignment? If this NSData was
loaded on a platform or with a compiler that aligns structs
differently, you'd have to be careful to get them out intact.
Admitted, that issue might be unimportant if you're only deploying
on Mac (which the majority of us are), but it'd probably be more
future-safe if you encoded the components of your structs and arrays
separately.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.