Weird crash issue on iOS 4.3

前端 未结 5 1860
广开言路
广开言路 2020-12-30 12:55

Since iOS 4.3 SDK is not in beta anymore, i believe i can talk about it here.

I\'m using UIApplicationExitsOnSuspend flag in my application to relaunch

5条回答
  •  情书的邮戳
    2020-12-30 13:29

    Google doesn't allow a single device to retrieve its location more than once within 60 sec, hence working with another method (http request instead, JSON needed) when (MKReverseGeocoder *)geocoder didFailWithError.

    It works for me on 4.3.3 (3GS) and tested for 30-40 times retrieving user's location consecutively without a crash, hope it helps!

    - (void) retrieveCurrentLoc {
    self.geoCoder =
    [[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate] autorelease];
        geoCoder.delegate = self;
    
        [geoCoder start];
    }
    
    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
    
    NSString *fetchURL = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?    q=%@,%@&output=json&sensor=true", [NSString     stringWithFormat:@"%f",mapView.userLocation.location.coordinate.latitude], [NSString      stringWithFormat:@"%f",mapView.userLocation.location.coordinate.longitude]];
        NSURL *url = [NSURL URLWithString:fetchURL];
        NSString *htmlData = [NSString stringWithContentsOfURL:url];
    
    SBJsonParser *parser = [[SBJsonParser alloc] init];
    NSDictionary *json = [parser objectWithString:htmlData error:nil];
    NSArray *placemark = [json objectForKey:@"Placemark"];
    if ([[[[[placemark objectAtIndex:0] objectForKey:@"AddressDetails"]objectForKey:@"Country"]objectForKey:@"Thoroughfare"]objectForKey:@"ThoroughfareName"] != NULL){
        currentAddress = [[[[[placemark objectAtIndex:0] objectForKey:@"AddressDetails"]objectForKey:@"Country"]objectForKey:@"Thoroughfare"]objectForKey:@"ThoroughfareName"];}
    else {
        currentAddress = [[placemark objectAtIndex:0] objectForKey:@"address"];
        }
    }
    

提交回复
热议问题