So, first stack overflow question but a long time reader ;)
My LocationManager settings are changing back to default when it reaches didUpdateLocations. I've set up an observer in viewDidLoad as well as some defaults like so. I'm also alloc ,initing, and setting the delegate of the locationManager before anything else.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(settingsDidChange:)
name:NSUserDefaultsDidChangeNotification
object:nil];
NSMutableDictionary *defaultsDictionary = [[NSMutableDictionary alloc] init];
[defaultsDictionary setObject:@(kCLLocationAccuracyNearestTenMeters) forKey:[SettingKeys LocationTrackingAccuracyPrefs]];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary];
Here is the settingsDidChange that is being observed and where I am attempting to set the desiredAccuracy of locationManager.
- (void)settingsDidChange:(NSNotification *)notification
{
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
CLLocationAccuracy desiredAccuracy = [settings doubleForKey:[SettingKeys LocationTrackingAccuracyPrefs]];
locationManager.desiredAccuracy = desiredAccuracy;
}
In a separate Settings view I am changing the value of desiredAccuracy which seems to be carrying over until it gets to didUpdateLocations. Then no matter what I set it to it seems to revert(or never change) to "Best" as the desiredAccuracy. I'm not sure what I'm missing here...I hope y'all can steer me in the right direction. Thanks!
Figured out my problem...further down in my settingsDidChange I was reallocating my LocationManager and that was causing it to revert to default settings. I feel stupid for not seeing it before! Thanks for the help anyway!
locationManager = [[CLLocationManager alloc] init];
ARRRGGG!!!