• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
KVC pitfall (was: validation)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KVC pitfall (was: validation)


  • Subject: KVC pitfall (was: validation)
  • From: Alexander Spohr <email@hidden>
  • Date: Wed, 21 Jan 2004 08:53:45 +0100

ho ho ho,

Am 20.01.2004 um 20:01 schrieb Geoff Hopson:

It's a kinda sorta coding style, I guess. The key value coding stuff looks for a method called someKey(), getSomeKey(), then an attribute _someKey and probably one or two more combos.

yep, here's the pit:

NSKeyValueCoding checks FIRST for isSomeKey() before trying someKey {the ivar}.
i think that's a bad idea!


example binding is
someRep: WORepetition {
	list = someList;
	item = someKey;
}

example code is
public String someKey; // as an iterator maybe
public boolean isSomeKey()
{
	return someKey != null;
}
// as i am lazy i do not implement someKey() for an iterator ivar here

guess what happens? we ran into that pit more than once. took us a while to find it in the first place. if you see it the second time you know what it is. but it is anoying that you can not name your methods/ivars as you like, because KVC is running through 10000 different checks to get that value.

http://developer.apple.com/documentation/WebObjects/Reference/API/com/ webobjects/foundation/NSKeyValueCoding.html
"For the key "lastName", this would be _lastName, _isLastName, lastName, or isLastName"


i don't understand the is<key> here. if i bind something to lastName i am surely talking about "Spohr", "Hopson" or "da Vinci". would anyone bind "van Gogh" to isLastName? i would bind something like
boolean isLastName()
{
return anArrayOfLastNames.containsObject(lastName)
}
to it.




As a side note, anyone know how to get Eclipse to auto-generate method names like the above, instead of set_myString and get_myString? Does that 'Accessor' service on MacOSX work with Java and Eclipse?

i just implemented a quick hack to parse objc. but it might be easy to convert that to java. did not try yet.
eclipse seems to show the services menu but everything is disabled in there.


	atze
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: validation (From: "Jonathan Fleming" <email@hidden>)
 >Re: validation (From: Drew Thoeni <email@hidden>)
 >Re: validation (From: Geoff Hopson <email@hidden>)

  • Prev by Date: Recover my sources.!!Urgent
  • Next by Date: link Framework in Eclipse
  • Previous by thread: Re: validation
  • Next by thread: JAI X-server Java 1.4 Security Problem.
  • Index(es):
    • Date
    • Thread