• 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: Justin Anderson <email@hidden>
  • Date: Mon, 19 Jan 2004 01:01:33 -0500

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.

What I'm really curious about is a good way to store binary tree structs...

- Justin

On Jan 18, 2004, at 11:50 PM, Aaron Boothello wrote:

Im kinda foreign to the concept of NSCoder and NSArchiver/Unarchiver, so please bear with me.

Ive managed to figure out how to save ints,floats,strings to a file and load em up again.

But now, im trying to save an array of objects, each of which are made up of an array of structs.
The structs are declared as follows:
struct pointStruct //POINTSTRUCT
{
float vertices[3]; //x,y,z coordinates
float offset[3]; //x,y,z offset
float scale[3]; //x,y,z scale
float angle[3]; //x,y,z angle

BOOL selectedPoint; //selected flag
};

struct planeStruct //PLANESTRUCT
{
struct pointStruct points[MAXPOINTS+1]; //pointStruct array
int pointCounter; //number of point in current plane
float offset[3]; //x,y,z offset
float scale[3]; //x,y,z scale
float angle[3]; //x,y,z angle
};


each of my objects is made up of an array of "planeStruct"....so how do i save the object out to a file, and load it back in when i need to ?

Thanks,
Aaron.
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: encoding structs (NSCoder / NSArchiver issue)
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: encoding structs (NSCoder / NSArchiver issue)
      • From: Chris Ridd <email@hidden>
References: 
 >encoding structs (NSCoder / NSArchiver issue) (From: Aaron Boothello <email@hidden>)

  • Prev by Date: Re: Codewarrior for Cocoa
  • Next by Date: Panther's Crash Reporter
  • Previous by thread: encoding structs (NSCoder / NSArchiver issue)
  • Next by thread: Re: encoding structs (NSCoder / NSArchiver issue)
  • Index(es):
    • Date
    • Thread