Iphone obtains the address details

Source: Internet
Author: User

The homepage has been revised to provide comments.

Iphone obtains the address details

-(Id) initWithCoordinate :( CLLocationCoordinate2D) coordinate {

If (self = [super init]) {

// Custom initialization

ReverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate: coordinate];

ReverseGeocoder. delegate = self;

[ReverseGeocoder start];

//......

}

Return self;

}

# Pragma mark MKReverseGeocoderDelegate

-(Void) reverseGeocoder :( MKReverseGeocoder *) geocoder didFailWithError :( NSError *) error

{

NSString * errorMessage = [error localizedDescription];

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @ "failed to obtain details"

Message: errorMessage

Delegate: nil

CancelButtonTitle: @ "OK"

OtherButtonTitles: nil];

[AlertView show];

[AlertView release];

}

-(Void) reverseGeocoder :( MKReverseGeocoder *) geocoder didFindPlacemark :( MKPlacemark *) placemark

{

NSLog (@ "% @", placemark. locality );

}

// ================================================ ========================

Street = No. 18 keyun Road

Thoroughfare = keyun Road

SubThoroughfare = 18

City = Guangzhou

SubLocality = Tianhe District

State = Guangdong Province

SubAdministrativeArea = (null)

ZIP = (null)

Country = China

{

City = "Guangzhou City ";

Country = "China ";

CountryCode = CN;

FormattedAddressLines = (

"China ",

"Tianhe District, Guangzhou City, Guangdong Province ",

"No. 18 keyun Road"

);

State = "Guangdong Province ";

Street = "No. 18 keyun Road ";

SubLocality = "Tianhe District ";

SubThoroughfare = "18 ";

Thoroughfare = "keyun Road ";

}

MKPlacemark:

@ Property (nonatomic, readonly) NSDictionary * addressDictionary; // address dictionary

@ Property (nonatomic, readonly) NSString * thoroughfare; // street name -- "keyun Road"

@ Property (nonatomic, readonly) NSString * subThoroughfare; // house number -- "18"

@ Property (nonatomic, readonly) NSString * locality; // City -- "Guangzhou City"

@ Property (nonatomic, readonly) NSString * subLocality; // district/county-"Tianhe District"

@ Property (nonatomic, readonly) NSString * administrativeArea; // identity -- "Guangdong Province"

@ Property (nonatomic, readonly) NSString * subAdministrativeArea; // No information is obtained. I don't know what it is.

@ Property (nonatomic, readonly) NSString * postalCode; // zip code -- I don't know why. I didn't get it here.

@ Property (nonatomic, readonly) NSString * country; // country-"China"

@ Property (nonatomic, readonly) NSString * countryCode; // country code -- "CN"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.