• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: encoding structs (NSCoder / NSArchiver issue)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: encoding structs (NSCoder / NSArchiver issue) (From: Justin Anderson <email@hidden>)

  • Prev by Date: Re: *****SPAM*****How to convince company I should switch to Cocoa
  • Next by Date: Can we set the height for a specific row in an NSTableView?
  • Previous by thread: Re: encoding structs (NSCoder / NSArchiver issue)
  • Next by thread: Re: encoding structs (NSCoder / NSArchiver issue)
  • Index(es):
    • Date
    • Thread