Re: How do I make NSData from cabron-Handle
Re: How do I make NSData from cabron-Handle
- Subject: Re: How do I make NSData from cabron-Handle
- From: Jim Correia <email@hidden>
- Date: Sat, 26 Jan 2002 11:09:37 -0500
At 5:53 PM +0200 1/26/02, Gore wrote:
hmm, yeah, but I want the data in the handle to be encoded, I want
the *data* to be saved to the HD using coco calls =)
possible ?
If the contents of the handle are flat (they don't reference external
structures) then it should be quite easy. Something like this (typed
into email client, not compiled, not tested)
- (NSData *)dataWithHandle:(Handle)h
{
// on 9 we would lock the handle, on X handles
// only move if you resize them
return [NSData dataWithBytes: (*h) length: GetHandleSize(h)];
}
- (Handle)newHandleFromData:(NSData *)
{
Handle h = NewHandle([data length]);
if (h != NULL)
[data getBytes: *h]
return h;
}