discuss-gnustep
[Top][All Lists]
Advanced

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

Re: KVC


From: Helge Hess
Subject: Re: KVC
Date: Wed, 6 Jun 2007 10:13:48 +0200

On Jun 6, 2007, at 24:14, Chris Farber wrote:
produces an exception because the ß can't be converted to ASCII. I recommend switching the conversion to UTF-8.
I don't believe this is an issue, as you cannot use unicode for variables or method names.

I'm talking about KVC, not methods and ivars. Key-Value Coding is defined in terms of

  - (id)valueForKey:(NSString *)_key
  - (void)setValue:(id)_value forKey:(NSString *)_key;

Given your argumentation I could not use @ or - in keys just because they are not allowed in vars/method-names.

No restrictions apply to the key. KVC is not just another way to access methods, its a concept on its own and in fact there are plenty of places where those methods are mapped to something which has nothing to do with methods. Eg one of the more complicated ones is D2WContext which maps keys to a rule system in Direct2Web.

Please remember that KVC is not just for accessing methods but for arbitary key/value combinations.
Perhaps you are thinking of NSMutableDictionary?

This is one of the simplest objects which modify the way KVC works. EOGenericRecord is another one and a good example where unicode plays a role (Given that eg PostgreSQL table, column names can be arbitary strings).

KVC is only for setting properties via appropriately named methods or direct access to instance variables.

Sorry??? Have you ever used WebObjects or EOF (or a clone of those)? :-) The power of KVC is that its separate. Eg it allows you to do trampolines like this:

  @implementation MyComponent
  - (id)labels {
    return self->labelHandler;
  }
  @end

  @implementation MyLabelHandler
  - (id)valueForKey:(NSString *)_key {
    return [[NSBundle bundle] labelForKey:_key];
  }
  @end

  LocalizableString.strings:
  WelcomeTitle = "Hello Friendly Visitor!!!";

And then in the WO template:
  <#WOString var:value="labels.WelcomeTitle" />



Anyways, to make a long story short: if you want to be compatible with Cocoa, you need to allow arbitary keys. This should hopefully stop further argumentation ;-)

Thanks,
  Helge

PS: its just a matter of time until UTF-8 is allowed in selectors. Java already does this (which BTW also affects KVC in combination with Java bridges ...)
--
Helge Hess
http://www.helgehess.eu/






reply via email to

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