【发布时间】:2012-02-06 09:51:28
【问题描述】:
我想在 Mapview 中添加注释,使用通过 URL 获取的 Json 数据。 可以吗?
NSMutableArray *annotations = [[NSMutableArray alloc]init];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://example.com/LData.php"]];
//Data: Longitud/Latitud/Country;.....
NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(str);
[foo removeAllObjects];
NSArray *foo2 =[str componentsSeparatedByString: @";"];
int i=0;
for(i=0;i<[foo2 count]; i++){
[foo insertObject:[foo2 objectAtIndex:i] atIndex:i];
NSArray *foo3 =[foo2 componentsSeparatedByString: @"/"];
到目前为止一切顺利 ¿ As I Lay 介绍变量 [i]?
CLLocationCoordinate2D theCoordinate[i];
theCoordinate1.latitude[i] = [foo3 objectAtIndex:1]);//Longitud
theCoordinate1.longitude[i] = [foo3 objectAtIndex:2]);//Latitud
MyAnnotation* myAnnotation[i]=[[MyAnnotation alloc] init];
myAnnotation[i].coordinate=theCoordinate[i];
myAnnotation[i].title=@""+[foo3 objectAtIndex:3];
myAnnotation[i].subtitle=@"in the city";
[mapView addAnnotation:myAnnotation[i]];
[annotations addObject:myAnnotation[i]];
}
我该如何解决这个问题?
【问题讨论】:
-
请清楚说明您遇到的问题。