Re: NSData question
Re: NSData question
- Subject: Re: NSData question
- From: Tommy Knowlton <email@hidden>
- Date: Tue, 02 Apr 2002 15:44:52 -0700
Jason,
*(cursor) is an in/out variable for the method. Declare a local unsigned,
initialized to zero, and pass that thing's address in the method call.
An NSData may contain the binary representation for any sequence of objects.
In this case, you're saying, "extract the raw bytes at offset (*cursor), for
length bytes, and copy them into the the region pointed to by buffer"
Initially, you'll say, "extract the XXX at offset zero", where *cursor is
zero when you call [myData deserializeXXX:(XXX *)pXXX ... atCursor:cursor].
Then, knowing that the next thing that was serialized in myData is a YYY,
and without necessarily knowing that the size of the XXX that already got
deserialized, you can call [myData deserializeYYY:(YYY *)pYYY ...
atCursor:cursor], passing in the same cursor. The call to deserializeXXX:
updated the unsigned that was pointed to, so that it records the offset
(within myData) of the "next" thing to deserialize.
Clear as mud? Hopefully I have helped not hurt your chances to understand
NSData.
Cheers,
--Tk!
>
Message: 14
>
Date: Tue, 2 Apr 2002 14:16:48 -0600
>
Subject: NSData question
>
From: Jason Moore <email@hidden>
>
To: CocoaDevList Apple <email@hidden>
>
>
Hello. Can anyone help me with NSData's=20
>
deserializeBytes:length:atCursor: method? It's exactly what i've been=20
>
looking for, but i'm having trouble getting it to work.
>
>
- (void)deserializeBytes:(void *)buffer length:(unsigned)bytes=20
>
atCursor:(unsigned *)cursor
>
>
i have a char* array i'm using for the 'buffer' argument, and an=20
>
unsigned int for 'bytes', but i'm not sure exactly how to do 'cursor'.=20
>
is it a pointer to an unsigned int? where should it start, the address=20
>
of the NSData objects' data or 0? The documentation is exceptionally=20
>
sparse for this one. Examples would be great. thanks again.
>
>
Jason
_______________________________________________
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.