To store a primitive type in an NSData object, you just need a pointer to the first byte of the value and the number of bytes:
Code:
double aDouble = 10.0;
NSData doubleData = [NSData dataWithBytes:&aDouble length:sizeof(double)];
You can get it back out like this:
Code:
double anotherDouble;
[doubleData getBytes:&anotherDouble length:sizeof(double)];