views:

60

answers:

1

I have a core location app that I'm writing leveraging the startMonitoringSignificantLocationChanges method to generate updates when appropriate but this does not work on older devices such as iPhone 3g.

I would like for the core location functionality to still work while the device is open, so I thought I could use a selector test to see if the device supports the method, and if it doesnt just use the standard core location updating method. Although this selector doesnt work on my iphone 3g, it still uses startMonitoringSignificantLocationChanges even though it doesnt work on the phone.

Any ideas? I would rather not use the device identifier tests because then it will have to be updated for every future release of the phone.

   @interface RootViewController : UITableViewController  <CLLocationManagerDelegate>  {
    CLLocationManager *locationManager;     
}
@property (nonatomic, retain) CLLocationManager *locationManager;

@implementation RootViewController
@synthesize locationManager;
    if([locationManager respondsToSelector:@selector(startMonitoringSignificantLocationChanges)]) {
            [locationManager startMonitoringSignificantLocationChanges];
            NSLog(@"Using bg updates");
        }
        else {
            [locationManager startUpdatingLocation];
            NSLog(@"Using reg updates");
        }
+1  A: 
if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
…
}
Pierre Bernard