adium 2895:c605b5914fee: make this more clearful.

commits at adium.im commits at adium.im
Sun Nov 8 06:51:21 UTC 2009


details:	http://hg.adium.im/adium/rev/c605b5914fee
revision:	2895:c605b5914fee
author:		Stephen Holt <sholt at adium.im>
date:		Sun Nov 08 01:50:29 2009 -0500

make this more clearful.

diffs (50 lines):

diff -r 9ddd18d9f12d -r c605b5914fee Frameworks/Adium Framework/Source/ESObjectWithProperties.m
--- a/Frameworks/Adium Framework/Source/ESObjectWithProperties.m	Sat Nov 07 20:23:39 2009 -0500
+++ b/Frameworks/Adium Framework/Source/ESObjectWithProperties.m	Sun Nov 08 01:50:29 2009 -0500
@@ -71,30 +71,24 @@
  * @param key The property to set the value to.
  * @param notify The notification timing. One of NotifyNow, NotifyLater, or NotifyNever.
  */
- - (void)setValue:(id)value forProperty:(NSString *)key notify:(NotifyTiming)notify
+- (void)setValue:(id)value forProperty:(NSString *)key notify:(NotifyTiming)notify
 {
-	if (key) {
-		if (value && [[self valueForKey:key] isEqual:value]) //No need to do all this work just to stay the same
-			return;
-		BOOL changedPropertiesDict = YES;
+    NSParameterAssert(key != nil);
+    id oldValue = [self valueForProperty:key];
+    if ((!oldValue && !value) ||
+        (value && [oldValue isEqual:value])) //No need to do all this work just to stay the same
+        return;
 
-		[self willChangeValueForKey:key];
-		if (value) {
-			[propertiesDictionary setObject:value forKey:key];
-		} else {
-			//If we are already nil and being told to set nil, we don't need to do anything at all
-			if ([propertiesDictionary objectForKey:key]) {
-				[propertiesDictionary removeObjectForKey:key];
-			} else {
-				changedPropertiesDict = NO;
-			}
-		}
-		
-		if (changedPropertiesDict) {
-			[self object:self didChangeValueForProperty:key notify:notify];
-		}
-		[self didChangeValueForKey:key];
-	}
+    [self willChangeValueForKey:key];
+    
+    if (value) {
+        [propertiesDictionary setObject:value forKey:key];
+    } else {
+        [propertiesDictionary removeObjectForKey:key];
+    }
+    
+    [self object:self didChangeValueForProperty:key notify:notify];
+    [self didChangeValueForKey:key];
 }
 
 /*!




More information about the commits mailing list