Setting corelocation results to NSNumber object parameters
        Posted  
        
            by Dan Ray
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Dan Ray
        
        
        
        Published on 2010-05-28T19:29:51Z
        Indexed on 
            2010/05/28
            19:31 UTC
        
        
        Read the original article
        Hit count: 576
        
iphone
|objective-c
This is a weird one, y'all.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    CLLocationCoordinate2D coordinate = newLocation.coordinate;
    self.mark.longitude = [NSNumber numberWithDouble:coordinate.longitude];
    self.mark.latitude = [NSNumber numberWithDouble:coordinate.latitude];
    NSLog(@"Got %f %f, set %f %f", coordinate.latitude, coordinate.longitude, self.mark.latitude, self.mark.longitude);
    [manager stopUpdatingLocation];
    manager.delegate = nil;
    if (self.waitingForLocation) {
        [self completeUpload];
    }
}
The latitude and longitude in that "mark" object are synthesized parameters referring to NSNumber iVars. 
In the simulator, my NSLog output for that line in the middle there reads:
2010-05-28 15:08:46.938 EverWondr[8375:207] Got 37.331689 -122.030731, set 0.000000 -44213283338325225829852024986561881455984640.000000
That's a WHOLE lot further East than 1 Infinite Loop! The numbers are different on the device, but similar--lat is still zero and long is a very unlikely high negative number.
Elsewhere in the controller I'm accepting a button press and uploading a file (an image I just took with the camera) with its geocoding info associated, and I need that self.waitingForLocation to inform the CLLocationManager delegate that I already hit that button and once its done its deal, it should go ahead and fire off the upload. Thing is, up in the button-click-receiving method, I test see if CL is finished by testing self.mark.latitude, which seems to be getting set zero...
© Stack Overflow or respective owner