Re: Problem in coding integers/floats
Re: Problem in coding integers/floats
- Subject: Re: Problem in coding integers/floats
- From: Nico <email@hidden>
- Date: Thu, 19 Dec 2002 19:31:23 +0100
Hi John,
if I understood you correctly:
In my app I save some parameters in a file.
Here is the function to convert a double
to an array of chars (bytes):
- (void)serializeDbl:(double*)value To:(char*)pByte
{
int i, steps;
char * pVoid = (char*)value;
steps = sizeof(double) / sizeof(char);
for (i = 0; i < steps; i++)
{
pByte[i] = *(pVoid+i);
}
}
When I load the data from a file I use NSData.
NSData provides the needed deserialisation.
I think there are better ways than using this
function, but it works...
Regards, Nico.
On Donnerstag, Dezember 19, 2002, at 02:22 Uhr, cocoa-dev-
email@hidden wrote:
Date: Thu, 19 Dec 2002 09:32:44 +0100
Subject: Problem in coding integers/floats
From: =?ISO-8859-1?Q?C=E9dric_John?= <email@hidden>
To: email@hidden
Ok, this might be a bit basic for you seasoned veterans out there, but
I do get trouble in archiving floats and integers. Basically, I don't
know how to properly use the "- encodeValuesOfObjCTypes:" methods. I've
tried to use some permutations of [coder
encodeValuesOfObjCTypes:@encode(int) anInt]; but without success. I
could not find a good documentation of the "@encode()" compiler
directive. Alternatively, I've archived a NSNumber, but I was really
disappointed because for some reasons it didn't record my float/int
correctly. So if someone could provide two lines of code, one for
coding and one for decoding an integer using
"encodeValuesOfObjCTypes:", I would be really grateful!
Cheereo
Cidric
Cidric John
---------------------------------
It is almost hopeless to try to get your email account from CROG.org,
but you can visit us online at http://www.crog.org !
_______________________________________________
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.