float[] in ObjectC

peteo
edited September 2011 in Native
C# code is below:

float[] position

var data = new Hashtable
{
{ (byte)ParameterCode.Position, position }
};


I want to know how to realize it in ObjectC ?

Comments

  • Hi peteo.
    We have a demo_iphone_photon_objC in the iPhone client SDK, which is demonstrating sending and receiving of different kinds of datatypes extensively.

    One of the examples therein is about sending a float-array as Hashtable-value:
    // NSString key and EGArray of float value:
    NSValue* valArray[10];
    float j=0.0f;
    for(int i=0; i<10; i++, j+=1.1f)
    	valArray[i] = [NSValue valueWithBytes:&j objCType:@encode(float)];
    [ev setObject:[EGArray arrayWithObjects:valArray count:10] forKey:[KeyObject withStringValue:@"testKey"]];
    

    accordingly with a byte-key like in your C# code, you could do it like this:
    // nByte key and EGArray of float value:
    NSValue* valArray[10];
    float j=0.0f;
    for(int i=0; i<10; i++, j+=1.1f)
    	valArray[i] = [NSValue valueWithBytes:&j objCType:@encode(float)];
    [ev setObject:[EGArray arrayWithObjects:valArray count:10] forKey:[KeyObject withByteValue:ParameterCode.Position]];