Is this possible with XCODE

Discussion in 'iOS Programming' started by hrithik123, Jun 17, 2011.

  1. hrithik123, Jun 17, 2011
    Last edited: Jun 17, 2011

    hrithik123 macrumors member

    Feb 3, 2010
    i want this to develop once functionality in xcode

    if user click on map button then the user's current location come and then Once address is received, display confirmation box and address is copied in the address text box.

    can any one know this type of functionality in xcode for iphone application?
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    XCode is an integrated development environment. It is not specifically tied to Cocoa, Cocoa Touch or any other set of APIs. I suspect the question you want to ask is "Is this possible using the iPhone SDK". In which case, yes, it is possible to retrieve the coordinates touched on the map, use a third party reverse geolocation service (the SDK does not provide this) and place the results from that in a text box.

    There are multiple, separate, steps here. I suggest you go and read the Location Awareness Programming Guide for the first part, do some Google searching to find, compare and choose a reverse geo-location API then read the URL Loading System Programming Guide to understand how you would talk to a webservice. Once you have that you will either need a framework (Google) or your own code (start with the NSString documentation) to parse the result into a NSString which can be displayed.

    I notice you are asking a lot of very generic questions without any code provided. People on this board tend to be willing to help solve specific problems with actual code but are less willing to write huge chunks of code for people for free. As such I suggest you ensure you know the basics and try solve each of the problems you've asked about yourself then come back and post specific questions about the problems you find.
  3. hrithik123 thread starter macrumors member

    Feb 3, 2010
    here is the code

    ----- LocationViewController.h-----
    #import <UIKit/UIKit.h>
    #import <CoreLocation/CoreLocation.h>	
    #import <MapKit/MapKit.h>
    @class RentalNote_iPhone1AppDelegate;
    @interface LocationViewController : UIViewController <CLLocationManagerDelegate,MKReverseGeocoderDelegate,MKMapViewDelegate> 
    	CLLocationManager *lm;
    	MKMapView *mapView;
    	RentalNote_iPhone1AppDelegate *mapappDelegate;
    @property (retain, nonatomic) CLLocationManager *locationManager;
    @property (retain, nonatomic) IBOutlet MKMapView *mapView;
    @property (nonatomic,retain) IBOutlet RentalNote_iPhone1AppDelegate *mapappDelegate;
    -(IBAction) removeMap: (id) sender;

    ----- LocationViewController.m------

    #import "LocationViewController.h"
    #import "DisplayMap.h"
    #import "RentalNote_iPhone1AppDelegate.h"
    #import "AddViewController.h"
    NSString *temp_locality,*locality,*temp_subAdministrativeArea,*subAdministrativeArea;
    NSString *temp_countryCode,*countryCode,*postalCode,*temp_address,*temp_address1,*temp_address2;
    @implementation LocationViewController
    @synthesize mapappDelegate;
    - (void) viewDidLoad 
    	lm = [[CLLocationManager alloc] init];
        lm.delegate = self;
        lm.desiredAccuracy = kCLLocationAccuracyBest;
        lm.distanceFilter = 1000.0f;
        [lm startUpdatingLocation];
    	mapView.delegate = self;
    /*   mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
    	mapView.mapType = MKMapTypeSatellite;
    	mapView.delegate = self;
    	[self.view addSubview:mapView];
    -(IBAction) removeMap: (id) sender 
    	[self dismissModalViewControllerAnimated:YES];
    - (void)mapView:(MKMapView *)mapView1 didUpdateUserLocation:(MKUserLocation *)userLocation
    	CLLocation *whereIAm = userLocation.location;
    	MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:whereIAm.coordinate];
    	reverseGeocoder.delegate = self;
    	[reverseGeocoder start];
    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark 
    	temp_locality = placemark.locality;
    	locality = [temp_locality stringByAppendingString:@","];
    	temp_subAdministrativeArea = placemark.subAdministrativeArea;
    	subAdministrativeArea = [temp_subAdministrativeArea stringByAppendingString:@","];
    	temp_countryCode = placemark.countryCode;
    	countryCode = [temp_countryCode stringByAppendingString:@" "];
    	postalCode = placemark.postalCode;
    	temp_address = [locality stringByAppendingString:subAdministrativeArea];
    	temp_address1 = [temp_address stringByAppendingString:countryCode];
    	temp_address2 = [temp_address1 stringByAppendingString:postalCode];
    	//	[self.view addSubview:tabBarViewController.view];
    	mapappDelegate = (RentalNote_iPhone1AppDelegate *) [[UIApplication sharedApplication] delegate];
    //	mapappDelegate.lblCommonAddress.text = temp_address2;
    	mapappDelegate.lblCommonAddress.text = @"Dipak";
    	NSLog(@"my ns string = %@", mapappDelegate.lblCommonAddress.text);
    //	txtAppAddress.text = temp_address2;
    - (void) locationManager: (CLLocationManager *) manager
    	 didUpdateToLocation: (CLLocation *) newLocation
    			fromLocation: (CLLocation *) oldLocation
    	CLLocation *whereIAm = newLocation;
    	MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:whereIAm.coordinate];
    	reverseGeocoder.delegate = self;
    	[reverseGeocoder start];
    	int degrees = newLocation.coordinate.latitude;
    	double decimal = fabs(newLocation.coordinate.latitude - degrees);
    	int minutes = decimal * 60;
    	double seconds = decimal * 3600 - minutes * 60;
       // NSString *lat = [[NSString alloc] initWithFormat:@"%g", 
    	//				 newLocation.coordinate.latitude];
     //   latitudeTextField.text = lat;
    	NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"", 
    					 degrees, minutes, seconds];
    	degrees = newLocation.coordinate.longitude;
    	decimal = fabs(newLocation.coordinate.longitude - degrees);
    	minutes = decimal * 60;
    	seconds = decimal * 3600 - minutes * 60;
    	NSString *lng = [NSString stringWithFormat:@"%d° %d' %1.4f\"", 
    					   degrees, minutes, seconds];
       // NSString *lng = [[NSString alloc] initWithFormat:@"%g", 
    	//				 newLocation.coordinate.longitude - degrees];
     //   longitudeTextField.text = lng;
    //    NSString *acc = [[NSString alloc] initWithFormat:@"%g", 
    //					 newLocation.horizontalAccuracy];
    //    accuracyTextField.text = acc;    
      //  [acc release];
        [lat release];
        [lng release];
    	MKCoordinateSpan span;
        MKCoordinateRegion region; = newLocation.coordinate;
    	DisplayMap *ann = [[DisplayMap alloc] init]; 
    	ann.title = @" Kolkata";
    	ann.subtitle = @"Mahatma Gandhi Road"; 
    	ann.coordinate =; 
    	[mapView addAnnotation:ann];
        [mapView setRegion:region animated:TRUE]; 
    -(void) locationManager: (CLLocationManager *) manager
    	   didFailWithError: (NSError *) error {
        NSString *msg = [[NSString alloc] 
    					 initWithString:@"Error obtaining location"];
        UIAlertView *alert = [[UIAlertView alloc]
                              cancelButtonTitle: @"Done"
        [alert show];    
        [msg release];
        [alert release];
    - (void)didReceiveMemoryWarning {
    	// Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];
    	// Release any cached data, images, etc that aren't in use.
    - (void)viewDidUnload {
    	// Release any retained subviews of the main view.
    	// e.g. self.myOutlet = nil;
    - (void) dealloc
    	[mapView release];
        [lm release];
        [super dealloc];
    i hope now you can help me
  4. robbieduncan Moderator emeritus


    Jul 24, 2002
    What is the question? In order to be helped you need to ask a specific, detailed question. Simply posting a load of code is not that. We are not going to sit and stare at that and try and work out what specific issue you are having in hour heads!
  5. hrithik123 thread starter macrumors member

    Feb 3, 2010
    sorry about this i am very new in this that is why some confusion

    aechully when i run this code in my xcode then in simulator i click on may it will going north America city.

    but i need to when i click on map then it will show current location

Share This Page