cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From torehal...@apache.org
Subject svn commit: r467765 - /incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m
Date Wed, 25 Oct 2006 21:04:45 GMT
Author: torehalset
Date: Wed Oct 25 14:04:44 2006
New Revision: 467765

URL: http://svn.apache.org/viewvc?view=rev&rev=467765
Log:
better persistent object description

Modified:
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m?view=diff&rev=467765&r1=467764&r2=467765
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m Wed Oct 25 14:04:44
2006
@@ -89,9 +89,33 @@
 
 -(NSString *)description
 {
+    NSMutableDictionary *descvalues = [[NSMutableDictionary alloc] init];
+    NSEnumerator *enumerator = [values keyEnumerator];
+    NSString *attrname;
+    while(attrname = [enumerator nextObject])
+    {
+        id value = [values objectForKey:attrname];
+        if([value isKindOfClass:[CAYPersistentObject class]])
+        {
+            [descvalues setObject:[value objectId] forKey:attrname];
+        }
+        else if ([value isKindOfClass:[NSArray class]])
+        {
+            [descvalues setObject:@"(..)" forKey:attrname];
+        }
+        else if ([value isKindOfClass:[CAYFault class]])
+        {
+            [descvalues setObject:@"?" forKey:attrname];
+        }
+        else
+        {
+            [descvalues setObject:value forKey:attrname];
+        }
+    }
+    
     NSString *result;
-	// TODO: it is dangerous to include relational values as it can result in a neverending
loop..
-    result = [[NSString alloc] initWithFormat:@"%@ {objectContext = %@; objectId = %@; values
= %@}", [self class], [self objectContext], [self objectId], /*values*/ @"...(TODO)...)"];
+    result = [[NSString alloc] initWithFormat:@"%@ {objectId = %@; values = %@}", [self class],
[self objectId], descvalues];
+    [descvalues release];
     [result autorelease];
     return result;
 }



Mime
View raw message