tags:

views:

28

answers:

0

Hi guys,

   Here Im getting problem I need to Get the full address of current location as:
   99 Infinite loop, Cupertino, CA 95014, USA.

As I am new to this topic I dont know how to get the full address using reverse geocoder.

I written My code as:

-(void)gettingCurrentLocation
{
CorkItAppDelegate* appDelegate = (CorkItAppDelegate*)[[UIApplication sharedApplication] delegate];

CLLocationCoordinate2D myLocation;
double latitude = 0.0;
double longitude = 0.0;

NSArray *listItems = [appDelegate.currentLocation componentsSeparatedByString:@","];

latitude=[[listItems objectAtIndex:0] doubleValue];
longitude=[[listItems objectAtIndex:1] doubleValue];
myLocation.latitude=latitude;
myLocation.longitude =longitude;
printf("\n======location.latitude=======%f",myLocation.latitude );
printf("\n======location.longitude=======%f",myLocation.longitude );

reverseGeocoder = [[MKReverseGeocoder alloc]initWithCoordinate:myLocation];
reverseGeocoder.delegate=self;
[reverseGeocoder start];
[refreshProgressInd stopAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
NSLog(@"Geocoder error");
} 

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"Geocoder completed");   
locationTextfield.text=placemark.postalCode;

}

Anyone's help will be much appreciated.

Thank you, Monish.