Revision: 3888
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3888&view=rev
Author:   hofman
Date:     2008-05-17 10:31:54 -0700 (Sat, 17 May 2008)

Log Message:
-----------
simplify code.

Modified Paths:
--------------
    trunk/NSUserDefaultsController_SKExtensions.m

Modified: trunk/NSUserDefaultsController_SKExtensions.m
===================================================================
--- trunk/NSUserDefaultsController_SKExtensions.m       2008-05-17 14:41:04 UTC 
(rev 3887)
+++ trunk/NSUserDefaultsController_SKExtensions.m       2008-05-17 17:31:54 UTC 
(rev 3888)
@@ -38,31 +38,28 @@
 
 #import "NSUserDefaultsController_SKExtensions.h"
 
+#define VALUES_KEY_PATH(key) [@"values." stringByAppendingString:key]
 
 @implementation NSUserDefaultsController (SKExtensions)
 
 - (void)addObserver:(NSObject *)anObserver forKey:(NSString *)key 
context:(void *)context {
-    [self addObserver:anObserver forKeyPath:[NSString 
stringWithFormat:@"values.%@", key] options:0 context:context];
+    [self addObserver:anObserver forKeyPath:VALUES_KEY_PATH(key) options:0 
context:context];
 }
 
 - (void)removeObserver:(NSObject *)anObserver forKey:(NSString *)key {
-    [self removeObserver:anObserver forKeyPath:[NSString 
stringWithFormat:@"values.%@", key]];
+    [self removeObserver:anObserver forKeyPath:VALUES_KEY_PATH(key)];
 }
 
 - (void)addObserver:(NSObject *)anObserver forKeys:(NSArray *)keys 
context:(void *)context {
     int i, iMax = [keys count];
-    for (i = 0; i < iMax; i++) {
-        NSString *keyPath = [NSString stringWithFormat:@"values.%@", [keys 
objectAtIndex:i]];
-        [self addObserver:anObserver forKeyPath:keyPath options:0 
context:context];
-    }
+    for (i = 0; i < iMax; i++)
+        [self addObserver:anObserver forKey:[keys objectAtIndex:i] 
context:context];
 }
 
 - (void)removeObserver:(NSObject *)anObserver forKeys:(NSArray *)keys {
     int i, iMax = [keys count];
-    for (i = 0; i < iMax; i++) {
-        NSString *keyPath = [NSString stringWithFormat:@"values.%@", [keys 
objectAtIndex:i]];
-        [self removeObserver:anObserver forKeyPath:keyPath];
-    }
+    for (i = 0; i < iMax; i++)
+        [self removeObserver:anObserver forKey:[keys objectAtIndex:i]];
 }
 
 - (void)revertToInitialValueForKey:(NSString *)key {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to