From: Joe Wreschnig Date: Fri, 15 Mar 2013 00:36:26 +0000 (+0100) Subject: Don't re-save mappings immediately upon load. X-Git-Tag: version-1.1~24 X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=764667945312ea9762fba3127ec175387fa0a930;p=enjoyable.git Don't re-save mappings immediately upon load. --- 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]; } }