And*_*son 1 iphone cocoa-touch objective-c
NSArray *splitPoints = [routeGeom componentsSeparatedByString:@"], ["];
routePoints = malloc(sizeof(CLLocationCoordinate2D) * ([splitPoints count] + 1));
int i=0;
NSArray *coords;
for (NSString* coordStr in splitPoints) {
coords = [coordStr componentsSeparatedByString:@","];
routePoints[i].latitude = [[[coords objectAtIndex:0] substringFromIndex:1]floatValue];
routePoints[i].longitude = [[coords objectAtIndex:1] floatValue];
i++;
}
[coords release];
NSLog(@"** Time to split the route geometry into structs %f", [NSDate timeIntervalSinceReferenceDate] - start);
Run Code Online (Sandbox Code Playgroud)
考虑:
char *buf = [coordStr UTF8String];
sscanf(buf, "%f,%f", &routePoints[i].latitude, routePoints[i].longitude);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
473 次 |
| 最近记录: |