gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KeyValueCoding (was Recent key-value encoding changes to NSObject.)


From: Manuel Guesdon
Subject: KeyValueCoding (was Recent key-value encoding changes to NSObject.)
Date: Sat, 23 Feb 2002 15:46:51 +0100 (CET)

On Sat, 23 Feb 2002 12:58:58 +0100 (CET) Manuel Guesdon <address@hidden> wrote:
 >| I've found also to feature wich could be interesting
 >|         o adding "special keys", may be by generalizing NSArray 
 >-computeXXforKey:
 >|                 An example, it would be nice to use something like
 >|                         address@hidden
 >|                 @currentLanguage will be binded in the current language 
 >code in this case.
 >|                 If we have this iordered language list (FR, EN, ES)
 >|                 The key will be result will be the same as:
 >|                         - anObject.aDictionary.FR
 >|                                 if there is a value for FR in aDictionary
 >|                         - otherwise anObject.aDictionary.EN
 >|                                 if there is a value for EN in aDictionary
 >|                         - otherwise anObject.aDictionary.ES
 >|                                 if there is a value for ES in aDictionary
 >|                         - otherwise, it will return nil.

        Sorry, it wasn't a really good exemple. A good one is when you need a 
'function' with a parameter 
                something like address@hidden
                which would call  -computeLocalizedLabelForKey:@"FR"
                and avoid creating and returning a dictionary of localized 
labels indexed on languages (speed and memory optimization).
                

 >|         o handling quotes in keys like
 >|                 anObject."a.Key".aName
 >|                 "a.Key" would be taken a a single key "a.key" not 2 keys 
 >"a" and "Key".

               the use of single quote (') may be better than using double 
quoyes (") because it " is already used in
WebObjects to specify constant string instead of KeyValue association.
                we could also use another syntax by introducing an escape 
character. For exemple:
                                anObject.a\\.Key.aName
                        

Is it possible to change the implementation of valueForKeyPath: and 
takeValue:forKeyPath: so it call
                -valueForKey:TheFirstKeyPathPart and call 
-valueForKeyPath:TheRemainderKeyPath on the returned object
         like Apple does instead of doing a loop of valueForKey: ?
      Doing that will offer more control on how each object handle this.

Manuel

--
______________________________________________________________________
Manuel Guesdon - OXYMIUM <address@hidden>
14 rue Jean-Baptiste Clement  -  93200 Saint-Denis  -  France
Tel: +33 1 4940 0999  -  Fax: +33 1 4940 0998




reply via email to

[Prev in Thread] Current Thread [Next in Thread]