ユーザーの場所を見つけてそれをラベルに返すコードがいくつかあります。場合によっては、subAdministrativeArea が利用できないか、大通りが利用できないため、文字列を変更して表示されないようにしたい (null)。これを確認するためにいくつか試してみましたが、(null)が複数ある場合は問題があります。誰でもこれについて考えがありますか?
目印オブジェクトがnullに等しいかどうかを検出するために変更する必要がある現在のコードは次のとおりです。
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocation *currentLocation = newLocation;
[location stopUpdatingLocation];
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
if (error == nil && [placemarks count] > 0) {
placemark = [placemarks lastObject];
countryDetected = placemark.ISOcountryCode;
placeLabel.text = [NSString stringWithFormat:@"%@, %@, %@, %@, %@ %@", placemark.country, placemark.subAdministrativeArea, placemark.subLocality, placemark.postalCode, placemark.thoroughfare, placemark.subThoroughfare];
userPlace = [NSString stringWithFormat:@"%@, %@, %@, %@, %@ %@", placemark.country, placemark.subAdministrativeArea, placemark.subLocality, placemark.postalCode, placemark.thoroughfare, placemark.subThoroughfare];
} else {
NSLog(@"%@", error.debugDescription);
}
} ];
}