i need to parse some paths of an SVG file, they are simple lines. When retrieving the data i end up with this string:
m 0,666.6479 254.28571,0
According to SVG specifications m denotes a new current point then the following 2 numbers are the position and the laters are relative positions to the first one.
So that would create a line from point (0, 666.6479) to (254.28, 666.64)
How can i parse that in Objective-C so i can end up with those 2 CGPoints or more if there were?
i know that if it finds an m, the following 2 comma separated numbers should be my first point and after each space there are 2 comma separated numbers that i should sum to the current point to get the next one.
What i don’t know if how to parse this correctly.
Thanks!
I would use C directly, as:
Please note that I just written that in the edit box, just take it as an example.
The other approach is to use
NSScanner, but I feel like the above approach is simpler as per your requirements.