From 764667945312ea9762fba3127ec175387fa0a930 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Fri, 15 Mar 2013 01:36:26 +0100 Subject: [PATCH] Don't re-save mappings immediately upon load. --- Classes/NJMappingsController.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Classes/NJMappingsController.m b/Classes/NJMappingsController.m index 4a9c3ff..fa851b1 100644 --- a/Classes/NJMappingsController.m +++ b/Classes/NJMappingsController.m @@ -46,8 +46,7 @@ return idx < _mappings.count ? _mappings[idx] : nil; } -- (void)mappingsChanged { - [self save]; +- (void)mappingsSet { [tableView reloadData]; [self updateInterfaceForCurrentMapping]; [NSNotificationCenter.defaultCenter @@ -57,6 +56,11 @@ NJMappingKey: _currentMapping }]; } +- (void)mappingsChanged { + [self save]; + [self mappingsSet]; +} + - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(__unsafe_unretained id [])buffer count:(NSUInteger)len { @@ -168,11 +172,7 @@ - (void)load { NSUInteger selected = [NSUserDefaults.standardUserDefaults integerForKey:@"selected"]; - NSArray *mappings = [NSUserDefaults.standardUserDefaults arrayForKey:@"mappings"]; - [self loadAllFrom:mappings andActivate:selected]; -} - -- (void)loadAllFrom:(NSArray *)storedMappings andActivate:(NSUInteger)selected { + NSArray *storedMappings = [NSUserDefaults.standardUserDefaults arrayForKey:@"mappings"]; NSMutableArray* newMappings = [[NSMutableArray alloc] initWithCapacity:storedMappings.count]; // Requires two passes to deal with inter-mapping references. First make @@ -195,7 +195,7 @@ if (selected >= newMappings.count) selected = 0; [self activateMapping:_mappings[selected]]; - [self mappingsChanged]; + [self mappingsSet]; } } -- 2.30.2