[MacRuby-devel] [MacRuby] #507: valueForKey(key) no longer working with NSManagedObject subclasses.

MacRuby ruby-noreply at macosforge.org
Mon Apr 19 18:23:45 PDT 2010


#507: valueForKey(key) no longer working with NSManagedObject subclasses.
-----------------------------------+----------------------------------------
 Reporter:  johnmacshea@…          |       Owner:  lsansonetti@…              
     Type:  defect                 |      Status:  new                        
 Priority:  major                  |   Milestone:                             
Component:  MacRuby                |    Keywords:  valueForKey, KVC, Core Data
-----------------------------------+----------------------------------------

Comment(by martinlagardette@…):

 Sorry, here is a real reduction that will correctly check:

 {{{
 #!ruby
 framework 'CoreData'

 class Student < NSManagedObject
   attr_accessor :age
 end

 if ARGV.count < 1
   puts "Usage: #{$0} <xcdatamodel file>"
   exit 1
 end

 # Compile the managed object model so we can open it
 `/Developer/usr/bin/momc #{ARGV[0]} /tmp/MacRubyCDKeyCheck.mom`
 model = NSURL.URLWithString("file:///tmp/MacRubyCDKeyCheck.mom")
 mom = NSManagedObjectModel.alloc.initWithContentsOfURL(model)
 s = Student.alloc.initWithEntity(mom.entitiesByName["Student"],
 insertIntoManagedObjectContext:nil)
 s.valueForKey("age")
 }}}

 This works by doing so:
 {{{
 $> macruby kvc.rb ~/Downloads/CDKeyCheck/MacRubyApp.xcdatamodel
 NSUnknownKeyException: [<Student 0x40073e9a0> valueForUndefinedKey:]: the
 entity Student is not key value coding-compliant for the key "age".
 (RuntimeError)
 $>
 }}}

 On trunk:
 {{{
 $> macruby kvc.rb ~/Downloads/CDKeyCheck/MacRubyApp.xcdatamodel
 nil
 $>
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/507#comment:3>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list