You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by to...@apache.org on 2006/10/12 01:07:12 UTC

svn commit: r463032 - in /incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne: CAYPersistentObject.h CAYPersistentObject.m

Author: torehalset
Date: Wed Oct 11 16:07:12 2006
New Revision: 463032

URL: http://svn.apache.org/viewvc?view=rev&rev=463032
Log:
changes that make it possible to define custom set/get methods
in an entity class

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

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h?view=diff&rev=463032&r1=463031&r2=463032
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h Wed Oct 11 16:07:12 2006
@@ -40,8 +40,8 @@
 -(NSMutableDictionary *)valuesRaw;
 -(void)createFaults;
 
--(void)setValue:(id)value forKey:(NSString *)key;
--(id)valueForKey:(NSString *)key;
+-(void)setPrimitiveValue:(id)value forKey:(NSString *)key;
+-(id)primitiveValueForKey:(NSString *)key;
 -(BOOL)validateValue:(id *)ioValue forKey:(NSString *)key error:(NSError **)outError;
 
 -(void)setToOneTarget:(CAYPersistentObject *)value forKey:(NSString *)key setReverse:(BOOL)setrev;

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m?view=diff&rev=463032&r1=463031&r2=463032
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m Wed Oct 11 16:07:12 2006
@@ -125,7 +125,7 @@
     }
 }
 
--(void)setValue:(id)value forKey:(NSString *)key
+-(void)setPrimitiveValue:(id)value forKey:(NSString *)key;
 {
     // NSLog(@"DEBUG: set value %@ for key %@ of type %@", value, key, [value class]);
     
@@ -198,7 +198,14 @@
     }
 }
 
--(id)valueForKey:(NSString *)key
+// this method is called if setValue:forKey: was not able to find a user defined set method for the key
+// see http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/SearchImplementation.html
+-(void)setValue:(id)value forUndefinedKey:(NSString *)key
+{
+    [self setPrimitiveValue:value forKey:key];
+}
+
+-(id)primitiveValueForKey:(NSString *)key
 {
     id val = [values objectForKey:key];
     if([val isKindOfClass:[CAYFault class]])
@@ -214,6 +221,13 @@
         return nil;
     }
     return val;
+}
+
+// this method is called if valueForKey: was not able to find a user defined get method for the key
+// see http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/SearchImplementation.html
+-(id)valueForUndefinedKey:(NSString *)key
+{
+    return [self primitiveValueForKey:key];
 }
 
 -(BOOL)validateValue:(id *)ioValue forKey:(NSString *)key error:(NSError **)outError