我需要使用CLGeocoder 而不是 Google API 对大量地址进行地理编码.
我的问题是我的代码只为下面数组中的第一个地址添加了注释.但是,函数被调用适当的次数 - 在为所有地址调用函数之后,块只运行第一个地址:
- (void)mapPoints {
NSString *foo = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"names%d", self.indexOfSchool] ofType:@"plist"];
NSArray *description = [NSArray arrayWithContentsOfFile:foo];
NSString *bar = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d1", self.indexOfSchool] ofType:@"plist"];
NSArray *details = [NSArray arrayWithContentsOfFile:bar];
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d0", self.indexOfSchool] ofType:@"plist"];
NSArray *addresses = [NSArray arrayWithContentsOfFile:path];
self.saved = [NSMutableArray alloc] init];
for (int q = 0; q < addresses.count; q+= 20) {
[self annotate:[addresses objectAtIndex:q] detail:[details objectAtIndex:q] andDesc:[description objectAtIndex:q]];
}
}
see updated …Run Code Online (Sandbox Code Playgroud)