[MacRuby] #601: hashes with empty values cannot writeToFile
#601: hashes with empty values cannot writeToFile --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- In objective c, empty values in nsdictionaries are handled by using the NSNull placeholder. Macruby replaces this with ruby nil on the ruby side. But when the writeToFile method is used on macruby hashes with such empty values, it fails. == code: == {{{ b={:k => NSNull.new} b.writeToFile("/tmp/bob", atomically:true) }}} == expected result == true, and a plist should be written to /tmp/bob == actual result == 0, and no file written -- Ticket URL: <http://www.macruby.org/trac/ticket/601> MacRuby <http://macruby.org/>
#601: hashes with empty values cannot writeToFile --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- Comment(by lastobelus@…): this is invalid, and came from my confusing setValue:forKey with setObject:forKey. setValue:forKey ignores nils, which is why the obj c code I was trying to convert worked. It was a series of setValue:forKey statements which I erringly replaced with a hash literal. -- Ticket URL: <http://www.macruby.org/trac/ticket/601#comment:1> MacRuby <http://macruby.org/>
#601: hashes with empty values cannot writeToFile --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- Comment(by martinlagardette@…): So does that mean this can be closed? -- Ticket URL: <http://www.macruby.org/trac/ticket/601#comment:2> MacRuby <http://macruby.org/>
#601: hashes with empty values cannot writeToFile --------------------------------+------------------------------------------- Reporter: lastobelus@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: Component: MacRuby | Resolution: invalid Keywords: | --------------------------------+------------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => invalid Comment: This is expected behavior. The same code in Objective-C also fails: {{{ $ cat /tmp/t.m #import <Foundation/Foundation.h> int main(void) { NSLog(@"-> %d", [[NSDictionary dictionaryWithObject:[NSNull null] forKey:@"foo"] writeToFile:@"/tmp/foo" atomically: YES]); return 0; } $ gcc /tmp/t.m -o /tmp/t -fobjc-gc -framework Foundation $ /tmp/t 2010-05-11 20:08:59.906 t[43283:107] -> 0 }}} The documentation for -[NSDictionary writeToFile:atomically:] states: {{{ This method recursively validates that all the contained objects are property list objects (instances of NSData, NSDate, NSNumber, NSString, NSArray, or NSDictionary) before writing out the file, and returns NO if all the objects are not property list objects, since the resultant file would not be a valid property list. }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/601#comment:3> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby