Hi All,
I am trying to read the "sphericalHarmonicsCoefficients: Data" object. I can print and see that the number of bytes is 108 in the retrieved object.
I use the below code to read the "Data" object into a "Float" array.
private func procSph(sphHar: Data) -> Array<Float32>
{
var sphCoeff = [Float]()
var bytes = [UInt8]()
var tmpByte: UInt8
var tmpSph: Data
var tmpFloat:Float = 0.0
var cnt:Int = 0
tmpSph = sphHar
for i in 0...107
{
cnt = cnt + 1
tmpByte = tmpSph.remove(at: i)
bytes.append(tmpByte)
if(cnt == 4)
{
memcpy(&tmpFloat, bytes, 4)
sphCoeff.append(tmpFloat)
cnt = 0
bytes.removeAll()
}
}
return sphCoeff
}
So basically I am extracting 4 bytes, converting them to "Float" storing them into array. The above code works fine till the 54th byte, and then it gives an exception in line no. 16 as I try to read the 55th byte.
Thanks for your help in advance _/\_
Best Regards,
Sumit