#751: Objects instantiated as anonymous class by Bindings mechanism --------------------------------+------------------------------------------- Reporter: wladj...@… | Owner: lsansone...@… Type: defect | Status: new Priority: minor | Milestone: MacRuby 0.6 Component: MacRuby | Keywords: --------------------------------+------------------------------------------- there is a problem with bindings mechanism in MacRuby 0.6 :
- create a new MacRuby Document based project - MyDocument.nib create a new ObjectController binded with File's Owner Content, model key path "dummy" create a new text field binded with ObjectController selection, model key path "name" - MyDocument.rb {{{ class MyDocument < NSDocument attr_accessor :dummy def init super setDummy({"name"=>"dummy"}) puts "in init class of Hash is : #...@dummy.class.ancestors}" return self end def windowNibName 'MyDocument' end # Document data representation for saving (return NSData) def dataOfType(type, error:outError) puts "in save class of Hash is : #...@dummy.class.ancestors}" return true end # Read document from data (return non-nil on success) def readFromData(data, ofType:type, error:outError) return true end # Return lowercase 'untitled', to comply with HIG def displayName fileURL ? super : super.sub(/^[[:upper:]]/) {|s| s.downcase} end end }}} bindings works, but when i try for to save the document, or already in the windowDidLoad (NSWindowController) method... {{{ in init class of Hash is : [Hash, NSMutableDictionary, NSDictionary, Enumerable, NSObject, Kernel] in save class of Hash is : [#<Class:0x200577420>, Hash, NSMutableDictionary, NSDictionary, Enumerable, NSObject, Kernel] }}} of course if i try to serialize the object i obtain : {{{ `fileWrapperOfType:error:': can't dump anonymous class #<Class:..........> (TypeError) }}} if i remove the bindings with text field all works again...well i mean no data in it, but at least the class of object remain the same as workaround i can create the hash via NSMutableDictionary.dictionary or in my case : {{{ temp = YAML::load( NSString.alloc.initWithData( fileWrapper.regularFileContents, encoding:NSString.defaultCStringEncoding)) @data = NSMutableDictionary.dictionary @data.setDictionary(temp) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/751> MacRuby <http://macruby.org/> _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel