From: Allison N. <dem...@ma...> - 2009-05-01 07:50:57
|
Hi everyone, I ran into a weird problem today, and I'm not sure if I'm doing something wrong, or if it's a bug in RubyCocoa. Here's the code: def test ary = NSMutableArray.alloc.init (0...100).each{|i| ary << NSObject.alloc.init} bad_array = [] (0...10).each{|i| bad_array << NSObject.alloc.init} ary -= bad_array end This always dies with the following 2009-05-01 09:39:04.138 PropertyInvestor[6113:10b] MainController#init: OSX::OCException: NSInvalidArgumentException - *** -[NSObject copyWithZone:]: unrecognized selector sent to instance 0x14beef00 /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/ oc_wrapper.rb:50:in `ocm_send' /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/ oc_wrapper.rb:50:in `method_missing' /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/ oc_attachments.rb:1328:in `-' /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/ oc_attachments.rb:1328:in `each' /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/ oc_attachments.rb:1328:in `-' /Users/demallien/Code/PropertyInvestor/PropertyInvestor/build/Debug/ PropertyInvestor.app/Contents/Resources/Database.rb:117:in `test' Now's where it gets weird. If I change ary to be a ruby array, making the code as follows: def test ary = NSMutableArray.alloc.init (0...100).each{ ary << NSObject.alloc.init} ary = [] + ary bad_array = [] (0...10).each{ bad_array << NSObject.alloc.init} ary -= bad_array end everything works just fine. Or if I fill the array with ruby objects rather than NSObjects, again, everything works fine, even if the enclosing array is an NSArray. Is this a bug in RubyCocoa? Or have I done something bad that you shouldn't do to NSArrays? Alli |