diff options
author | Jason Wray <jason@mapbox.com> | 2019-06-17 17:16:02 -0700 |
---|---|---|
committer | Jason Wray <friedbunny@users.noreply.github.com> | 2019-06-19 16:35:26 -0700 |
commit | 3d6da490735fa0874cf01804c8e7299e120393f1 (patch) | |
tree | 1f419878bd9bea1fd57595e8c8b3487b52566665 /platform/ios | |
parent | 3f9fd46fd4e4c22fe0779c56b2f701e423f2d909 (diff) | |
download | qtlocation-mapboxgl-3d6da490735fa0874cf01804c8e7299e120393f1.tar.gz |
[ios] Address iosapp state manager tailwork
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/app/MBXState.m | 17 | ||||
-rw-r--r-- | platform/ios/app/MBXStateManager.m | 11 |
2 files changed, 20 insertions, 8 deletions
diff --git a/platform/ios/app/MBXState.m b/platform/ios/app/MBXState.m index 49ccd67e8d..0365306637 100644 --- a/platform/ios/app/MBXState.m +++ b/platform/ios/app/MBXState.m @@ -21,9 +21,9 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled"; - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeObject:_camera forKey:MBXCamera]; - [coder encodeObject:[NSNumber numberWithInt:_userTrackingMode] forKey:MBXUserTrackingMode]; + [coder encodeObject:[NSNumber numberWithUnsignedInteger:_userTrackingMode] forKey:MBXUserTrackingMode]; [coder encodeBool:_showsUserLocation forKey:MBXShowsUserLocation]; - [coder encodeObject:[NSNumber numberWithInt:_debugMask] forKey:MBXDebugMaskValue]; + [coder encodeObject:[NSNumber numberWithUnsignedInteger:_debugMask] forKey:MBXDebugMaskValue]; [coder encodeBool:_showsZoomLevelOrnament forKey:MBXShowsZoomLevelOrnament]; [coder encodeBool:_showsTimeFrameGraph forKey:MBXShowsTimeFrameGraph]; [coder encodeBool:_debugLoggingEnabled forKey:MBXDebugLoggingEnabled]; @@ -68,7 +68,18 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled"; } - (NSString*) debugDescription { - return [NSString stringWithFormat:@"Camera: %@\nTracking mode: %lu\nShows user location: %@\nDebug mask value: %lu\nShows zoom level ornament: %@\nShows time frame graph: %@\nDebug logging enabled: %@\nShows map scale: %@\nShows user heading indicator: %@\nFramerate measurement enabled: %@", self.camera, (unsigned long)self.userTrackingMode, (self.showsUserLocation) ? @"YES" : @"NO", (unsigned long)self.debugMask, (self.showsZoomLevelOrnament) ? @"YES" : @"NO", (self.showsTimeFrameGraph) ? @"YES" : @"NO", (self.debugLoggingEnabled) ? @"YES" : @"NO", (self.showsMapScale) ? @"YES" : @"NO", (self.showsUserHeadingIndicator) ? @"YES" : @"NO", (self.framerateMeasurementEnabled) ? @"YES" : @"NO", (self.reuseQueueStatsEnabled) ? @"YES" : @"NO"]; + return [NSString stringWithFormat:@"Camera: %@\nTracking mode: %lu\nShows user location: %@\nDebug mask value: %lu\nShows zoom level ornament: %@\nShows time frame graph: %@\nDebug logging enabled: %@\nShows map scale: %@\nShows user heading indicator: %@\nFramerate measurement enabled: %@\nReuse queue stats enabled: %@", + self.camera, + (unsigned long)self.userTrackingMode, + self.showsUserLocation ? @"YES" : @"NO", + (unsigned long)self.debugMask, + self.showsZoomLevelOrnament ? @"YES" : @"NO", + self.showsTimeFrameGraph ? @"YES" : @"NO", + self.debugLoggingEnabled ? @"YES" : @"NO", + self.showsMapScale ? @"YES" : @"NO", + self.showsUserHeadingIndicator ? @"YES" : @"NO", + self.framerateMeasurementEnabled ? @"YES" : @"NO", + self.reuseQueueStatsEnabled ? @"YES" : @"NO"]; } @end diff --git a/platform/ios/app/MBXStateManager.m b/platform/ios/app/MBXStateManager.m index 679a4a075f..7203ae462d 100644 --- a/platform/ios/app/MBXStateManager.m +++ b/platform/ios/app/MBXStateManager.m @@ -3,6 +3,8 @@ #import "MBXState.h" #import "MBXViewController.h" +static NSString * const MBXStateManagerMapStateKey = @"mapStateKey"; + @interface MBXStateManager() @property (strong, nonatomic) MBXState *currentState; @@ -22,20 +24,19 @@ } - (MBXState*)currentState { - NSData *encodedMapState = [[NSUserDefaults standardUserDefaults] objectForKey:@"mapStateKey"]; - MBXState *currentState = (MBXState *)[NSKeyedUnarchiver unarchiveObjectWithData: encodedMapState]; + NSData *encodedMapState = [[NSUserDefaults standardUserDefaults] objectForKey:MBXStateManagerMapStateKey]; + MBXState *currentState = (MBXState *)[NSKeyedUnarchiver unarchiveObjectWithData:encodedMapState]; return currentState; } - (void)saveState:(MBXState*)mapState { NSData *encodedMapState = [NSKeyedArchiver archivedDataWithRootObject:mapState]; - [[NSUserDefaults standardUserDefaults] setObject:encodedMapState forKey:@"mapStateKey"]; - [[NSUserDefaults standardUserDefaults] synchronize]; + [[NSUserDefaults standardUserDefaults] setObject:encodedMapState forKey:MBXStateManagerMapStateKey]; } - (void)resetState { - [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"mapStateKey"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:MBXStateManagerMapStateKey]; } |