I am currently writing an OBJ wavefront loader in Objective-C, and I am trying to figure out how to parse data from NSString similarly to the sscanf () function in C.
OBJ files define faces in x, y, z triplets of vertices, texture coordinates and normals, such as:
f 1.43//2.43 1.11//2.33 3.14//0.009
At the moment, I'm not interested in the texture coordinates. In C, a simple way to parse this line would look like this:
sscanf(buf, "f %d//%d %d//%d %d//%d", &temp[0], &temp[1], &temp[2], &temp[3], &temp[4], &temp[5]);
Obviously, NSStrings cannot be used in sscanf () without first converting them to a C-style string, but I wonder if there is a more elegant way to do this without such a conversion.
objective-c cocoa 3d
user1034196
source share