Don't re-save mappings immediately upon load.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Fri, 15 Mar 2013 00:36:26 +0000 (01:36 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Fri, 15 Mar 2013 00:36:26 +0000 (01:36 +0100)
Classes/NJMappingsController.m

index 4a9c3fffaba6ccc82c42fde5cf827bbd10a65b00..fa851b15629e23c098b3a1809899f7285a966b5f 100644 (file)
@@ -46,8 +46,7 @@
     return idx < _mappings.count ? _mappings[idx] : nil;
 }
 
-- (void)mappingsChanged {
-    [self save];
+- (void)mappingsSet {
     [tableView reloadData];
     [self updateInterfaceForCurrentMapping];
     [NSNotificationCenter.defaultCenter
                                 NJMappingKey: _currentMapping }];
 }
 
+- (void)mappingsChanged {
+    [self save];
+    [self mappingsSet];
+}
+
 - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
                                   objects:(__unsafe_unretained id [])buffer
                                     count:(NSUInteger)len {
 
 - (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
         if (selected >= newMappings.count)
             selected = 0;
         [self activateMapping:_mappings[selected]];
-        [self mappingsChanged];
+        [self mappingsSet];
     }
 }