Reputation: 387
What is the most efficient way to convert a NSData to a float array?
I've the following:
NSData* dataOutputNumDetections = [outputNumDetections dataWithError:&error];
NSLog(@"%@",dataOutputScore);
Resulting this:
{length = 100, bytes = 0xf1699f3e cef5953e 32278d3e ae668b3e ... 6606483e 64ff463e }
NSData dataOutputNumDetections
contains 25 float32 values. I would like to convert all the bytes values and store the result in a size 25 float array.
Is it possible?
Upvotes: 1
Views: 598
Reputation: 387
This works
float output[25];
[dataOutputScore getBytes:output length:(sizeof(float) * 25)];
Upvotes: 1