I was wondering if there is a convenience method or something to change a NSString to an array of floats, for example.
I have a string which reads like this:
{{-0.528196, -0.567599, -0.631538, 0}, {0.0786662, -0.773265, 0.629184, 0}, {-0.845471, 0.282651, 0.453086, 0}, {0, 0, 0, 1}}
Which I got by the method:
NSStringFromGLKMatrix4()
And i want to do this:
float test[4][4] = {{-0.528196, -0.567599, -0.631538, 0}, {0.0786662, -0.773265, 0.629184, 0}, {-0.845471, 0.282651, 0.453086, 0}, {0, 0, 0, 1}};
return GLKMatrix4MakeWithArray(*test);
Any help will be appreciated, thanks.
This is kinda ugly, but it should work:
If you’re targeting iOS 4.0 or higher, you might also use
NSRegularExpressionto get the numbers out of the string.