Sunday, 15 April 2012

ios - Address/Zip Code as NSString to CLLocation -



ios - Address/Zip Code as NSString to CLLocation -

is there way convert zip code user enters textbox , convert cllocation? trying compare distance between current location , either address or zip code , easy if can create cllocation out of nsstring.

the procedure called geocoding, , how looks if implement it:

nstring *_address = // address or postcode clgeocoder *_geocoder = [[clgeocoder alloc] init]; [_geocoder geocodeaddressstring:_address completionhandler:^(nsarray *placemarks, nserror *error) { if (placemarks.count > 0) { clplacemark *_placemark = [placemarks firstobject]; cllocation *_location = _placemark.location; // ... whaterver want location } }];

note: the corelocation.framework has added project properly. may need handle errors in final completion-block, have not added such part code above.

ios cllocationmanager cllocation

No comments:

Post a Comment