From 79dc20808fd4ed72922742fa650a0dd1bbdc9038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 8 Sep 2015 14:21:03 -0700 Subject: [PATCH] Prefix user defaults in iosapp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We technically don’t need to, but the demo app should practice good hygiene since we expect developers to copy from it. --- ios/app/MBXViewController.mm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index d94e41b5f..bb35a0791 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -31,9 +31,9 @@ static NSUInteger const kStyleVersion = 8; if (self == [MBXViewController class]) { [[NSUserDefaults standardUserDefaults] registerDefaults:@{ - @"userTrackingMode": @(MGLUserTrackingModeNone), - @"showsUserLocation": @NO, - @"debug": @NO, + @"MBXUserTrackingMode": @(MGLUserTrackingModeNone), + @"MBXShowsUserLocation": @NO, + @"MBXDebug": @NO, }]; } } @@ -91,10 +91,10 @@ static NSUInteger const kStyleVersion = 8; { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSData *archivedCamera = [NSKeyedArchiver archivedDataWithRootObject:self.mapView.camera]; - [defaults setObject:archivedCamera forKey:@"camera"]; - [defaults setInteger:self.mapView.userTrackingMode forKey:@"userTrackingMode"]; - [defaults setBool:self.mapView.showsUserLocation forKey:@"showsUserLocation"]; - [defaults setBool:self.mapView.debugActive forKey:@"debug"]; + [defaults setObject:archivedCamera forKey:@"MBXCamera"]; + [defaults setInteger:self.mapView.userTrackingMode forKey:@"MBXUserTrackingMode"]; + [defaults setBool:self.mapView.showsUserLocation forKey:@"MBXShowsUserLocation"]; + [defaults setBool:self.mapView.debugActive forKey:@"MBXDebug"]; [defaults synchronize]; } } @@ -103,21 +103,21 @@ static NSUInteger const kStyleVersion = 8; { if (self.mapView) { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSData *archivedCamera = [defaults objectForKey:@"camera"]; + NSData *archivedCamera = [defaults objectForKey:@"MBXCamera"]; MGLMapCamera *camera = archivedCamera ? [NSKeyedUnarchiver unarchiveObjectWithData:archivedCamera] : nil; if (camera) { self.mapView.camera = camera; } - NSInteger uncheckedTrackingMode = [defaults integerForKey:@"userTrackingMode"]; + NSInteger uncheckedTrackingMode = [defaults integerForKey:@"MBXUserTrackingMode"]; if (uncheckedTrackingMode >= 0 && (NSUInteger)uncheckedTrackingMode >= MGLUserTrackingModeNone && (NSUInteger)uncheckedTrackingMode <= MGLUserTrackingModeFollowWithCourse) { self.mapView.userTrackingMode = (MGLUserTrackingMode)uncheckedTrackingMode; } - self.mapView.showsUserLocation = [defaults boolForKey:@"showsUserLocation"]; - self.mapView.debugActive = [defaults boolForKey:@"debug"]; + self.mapView.showsUserLocation = [defaults boolForKey:@"MBXShowsUserLocation"]; + self.mapView.debugActive = [defaults boolForKey:@"MBXDebug"]; } }