char *buf = [routeGeom UTF8String];
int bestGuess = 1 << (whatever);
routePoints = malloc(sizeof(CLLocationCoordinate2D) * bestGuess);
for (int i = 0; buf != NULL; buf = strchr(buf+1,'['), ++i) {
if (i >= bestGuess) {
bestGuess <<= 1;
routePoints = realloc(routePoints, sizeof(CLLocationCoordinate2D) * bestGuess);
}
sscanf(buf+1, "%f,%f,", &(routePoints + i)->latitude, &(routePoints + i)->longitude);
}
(whatever), 2 any . , , . , , , , routePoints, , realloc.
Edit:
. , CLLocationCoordinate2D 2 , .
char *buf = [routeGeom UTF8String];
int bestGuess = 1 << (whatever);
float *tmpFloats = (float *)malloc(sizeof(float) * bestGuess);
float *index = tmpFloats;
for (int i = 0; buf != NULL; buf = strchr(buf+1,'['), ++i, index += 2) {
if (i >= bestGuess) {
bestGuess <<= 1;
tmpFloats = (float *)realloc(tmpFloats, sizeof(float) * bestGuess);
}
sscanf(buf+1, "%f,%f,", index, index + 1);
}
CLLocationCoordinate2D *routePoints = (CLLocationCoordinate2D *)tmpFloats;