• 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
Re: New NSKeyValueCoding in 5.4
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New NSKeyValueCoding in 5.4


  • Subject: Re: New NSKeyValueCoding in 5.4
  • From: Alexander Spohr <email@hidden>
  • Date: Tue, 11 Dec 2007 22:49:29 +0100

Hi Ryan.

Am 11.12.2007 um 19:46 schrieb Ryan Klems:

This is true, although a get will also check for the special keywords values, keySet, size, and entrySet, returning those method calls on the Map (similar to how valueForKey behaves on an NSDictionary). If you want to alter this behavior I would recommend implementing the KeyValueCoding interface on your object.
-Ryan

That would result in something like this:

public Object valueForKey(String key) {
	if("instacevar1".equals(key))
		return instancevar1();
	if("instacevar2".equals(key))
		return instancevar2();
	if("instacevar3".equals(key))
		return instancevar3();
...
	if("instacevarN".equals(key))
		return instancevarN();

	return NSKeyValueCoding.MapImplementation.valueForKey(this, key);
}

This looks not like an opinion - or even like a part of a WebObjects- app.
Please provide a public method that just checks ivars/methods and does not try to be smarter than me by caring automagically for Maps - or just revert the old one ;)


	atze

PS. If you implement a special treat for Map why not add Lists? Like valueForKey works on NSArray. It is inconsistent right now.


On Dec 11, 2007, at 7:58 AM, Alexander Spohr wrote:

FYI:

The behavior of NSKeyValueCoding.DefaultImplementation has changed.

If you used subclasses of Maps and wanted to add instance variables to be used by NSKeyValueCoding the following was a valid method inside your MapSubclass:

public Object valueForKey(String key) {
Object retVal = null;
try {
retVal = NSKeyValueCoding.DefaultImplementation.valueForKey(this, key);
} catch (Exception e) {
retVal = this.get(key);
}
return retVal;
}


This behavior does not work anymore!

If NSKeyValueCoding.DefaultImplementation gets a Map it forwards the request to MapImplementation which ONLY asks for map.get(key) and returns null if there is no such key. You can not get to any instance-variable using NSKeyValueCoding anymore as all Maps are redirected to the new (non-documented) MapImplementation.valueForKey().

	atze

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


Freeport & Soliversum Alexander Spohr email@hidden www.freeport.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: New NSKeyValueCoding in 5.4
      • From: Anjo Krank <email@hidden>
References: 
 >New NSKeyValueCoding in 5.4 (From: Alexander Spohr <email@hidden>)
 >Re: New NSKeyValueCoding in 5.4 (From: Ryan Klems <email@hidden>)

  • Prev by Date: WOLips and JC
  • Next by Date: Re: New NSKeyValueCoding in 5.4
  • Previous by thread: Re: New NSKeyValueCoding in 5.4
  • Next by thread: Re: New NSKeyValueCoding in 5.4
  • Index(es):
    • Date
    • Thread