I'm not sure if this is how you code your value, but it can help to encapsulate your array into a structure.
typedef struct
{
float values[3];
} PosValues;
In your code:
PosValues p1 = { { 1.0, 2.0, 3.0 } };
NSValue *val = [NSValue valueWithBytes:&p1 objCType:@encode(PosValues)];
PosValues p2;
[val getValue:&p2];
NSLog(@"%f, %f, %f", p2.values[0], p2.values[1]. p2.values[2]);
The advantage of this approach is that your array is stored as an array type. In addition, these structures can be assigned, although the original arrays are not:
PosValues p1 = { { 1.0, 2.0, 3.0 } };
PosValues p2;
p2 = p1;
source
share