CLLocation doesnt work. help.

Discussion in 'iOS Programming' started by alexandergre, Jan 31, 2010.

  1. alexandergre macrumors member

    alexandergre

    Joined:
    Jul 28, 2009
    #1
    xAppDelegate.h
    Code:
    NSNumber *currentLatitude;
    NSNumber *currentLongitude;
    CLLocationManager *locationManager;
    xAppDelegate.m
    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    	
    	
    	CLLocation *location = [locationManager location];
    	CLLocationCoordinate2D coordinate = [location coordinate];
    	currentLongitude = [NSNumber numberWithDouble:coordinate.longitude];
    	currentLatitude = [NSNumber numberWithDouble:coordinate.latitude];
    	
    	NSLog([NSString stringWithFormat:@"%@ , %@", currentLatitude, currentLongitude]);
    	
    	
    	[window addSubview:[navigationController view]];
    	[window makeKeyAndVisible];
    }
    tested the code on iPhone 3gs
    and the debugger gives me:
    0 , 5.862950985069642e-37

    what is wrong?
    thanx
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Most likely nothing is wrong: you should be giving an accuracy you desire and registering for updates from CL. The documentation (which you should have read) says:

    "To use a CLLocationManager object to deliver location events, create an instance, assign a delegate object to it, configure the desired accuracy and distance filter values, and call the startUpdatingLocation method. The location service returns an initial location as quickly as possible, returning cached information when available. After delivery of the initial event notification, the CLLocationManager object may deliver additional events if the minimum threshold distance (as specified by the distanceFilter property) is exceeded or a more accurate location value is determined."
     
  3. alexandergre thread starter macrumors member

    alexandergre

    Joined:
    Jul 28, 2009
    #3
    thanx a lot.
    problem resolved :D:D:D::D:D
     

Share This Page