#1433: Defining valueForUndefinedKey after an NSUnknownKeyException has been raised fails -----------------------------------+---------------------------------------- Reporter: ndh@… | Owner: lsansonetti@… Type: defect | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: -----------------------------------+---------------------------------------- When you define #valueForUndefinedKey on a class after calling #valueForKey on an instance of that class, the new definition is ignored for that instance as well as new instances. This is probably a minor issue because I doubt that classes are reopened to redefine valueForUndefinedKey on a regular basis. When I run the following script, I get this output $ ruby -v MacRuby 0.10 (ruby 1.9.2) [universal-darwin10.0, x86_64] $ ruby unknown_value.rb NSUnknownKeyException: [<Foo 0x200052ca0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key qux. /Users/nick/macRubyBook/ch06/value_error.rb:19:in `<main>': NSUnknownKeyException: [<Foo 0x200052ca0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key qux. (RuntimeError) class Foo attr_accessor :bar end foo = Foo.new foo.bar = 'baz' begin foo.valueForKey("qux") rescue => e puts e end class Foo def valueForUndefinedKey(key) p key end end p foo.valueForKey("qux") -- Ticket URL: <http://www.macruby.org/trac/ticket/1433> MacRuby <http://macruby.org/>