for (id obj in studentArray) 仅遍历数组中的第一项

for (id obj in studentArray) only iterating through first item in array

下面假设 运行 通过 NSMutableArray of *Studentsaddress 属性。但出于某种原因,for 并未遍历整个 NSMutableArray,仅遍历第一个对象。

CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    for (id obj in studentArray) {
        if ([obj isKindOfClass:[Student class]]) {
            Student *selectedStudent = obj;
            [geocoder geocodeAddressString:selectedStudent.address completionHandler:^(NSArray* placemarks, NSError* error){
                for (CLPlacemark* aPlacemark in placemarks)
                {
                    NSString *latDest1 = [NSString stringWithFormat:@"%.4f",aPlacemark.location.coordinate.latitude];
                    NSString *lngDest1 = [NSString stringWithFormat:@"%.4f",aPlacemark.location.coordinate.longitude];
                    NSLog(@"%@, %@",latDest1, lngDest1);
                }
            }];
        }
    }

知道我可能做错了什么吗?该应用程序不会崩溃,只是简单地检查数组中的 4 个学生之一。 谢谢

地理编码似乎没有 return 下一个 Student 对象的地标。问题可能是因为太多的地理编码请求。 来自有关地理编码的 Apple 文档:

After initiating a forward-geocoding request, do not attempt to initiate another forward- or reverse-geocoding request. Geocoding requests are rate-limited for each app, so making too many requests in a short period of time may cause some of the requests to fail. When the maximum rate is exceeded, the geocoder passes an error object with the value network to your completion handler.