orthehelper
orthehelper

Reputation: 4079

How to get house number with MKPlacemark

i can get the street and city by applying this code to the MKReversegeocoder

NSString* city = [placemark.addressDictionary valueForKey:@"City"];
NSString* street = [placemark.addressDictionary valueForKey:@"Street"]; 

now i am trying to get the street number is it possible?

Upvotes: 2

Views: 1798

Answers (2)

dang
dang

Reputation: 1588

self.userCoord = [[CLLocation alloc] initWithLatitude:geoPoint.latitude longitude:geoPoint.longitude];

        CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
        [geoCoder reverseGeocodeLocation:self.userCoord  completionHandler:^(NSArray *placemarks, NSError *error)
        {
            if (error == nil && [placemarks count] > 0)
            {
              CLPlacemark *placemark = [placemarks lastObject];
              self.city.text = placemark.locality;
              self.street.text = placemark.thoroughfare;
              self.house.text = place mark.subThoroughfare;
            }
        }
// address dictionary properties
@property (nonatomic, readonly, copy) NSString *name; // eg. Apple Inc.
@property (nonatomic, readonly, copy) NSString *thoroughfare; // street address, eg. 1 Infinite Loop
@property (nonatomic, readonly, copy) NSString *subThoroughfare; // eg. 1
@property (nonatomic, readonly, copy) NSString *locality; // city, eg. Cupertino
@property (nonatomic, readonly, copy) NSString *subLocality; // neighborhood, common name, eg. Mission District
@property (nonatomic, readonly, copy) NSString *administrativeArea; // state, eg. CA
@property (nonatomic, readonly, copy) NSString *subAdministrativeArea; // county, eg. Santa Clara
@property (nonatomic, readonly, copy) NSString *postalCode; // zip code, eg. 95014
@property (nonatomic, readonly, copy) NSString *ISOcountryCode; // eg. US
@property (nonatomic, readonly, copy) NSString *country; // eg. United States
@property (nonatomic, readonly, copy) NSString *inlandWater; // eg. Lake Tahoe
@property (nonatomic, readonly, copy) NSString *ocean; // eg. Pacific Ocean
@property (nonatomic, readonly, copy) NSArray *areasOfInterest; // eg. Golden Gate Park

Upvotes: 4

Mark Adams
Mark Adams

Reputation: 30846

I think what you're looking for is the subThoroughfare property of MKPlacemark. Note that in iOS 5.0+, subThoroughfare isn't declared on MKPlacemark. It now inherits this from the new superclass, CLPlacemark.

Upvotes: 3

Related Questions