From: Kei T. <ke...@pa...> - 2009-05-28 09:12:08
|
Hi, I am using CoreAnimation from RubyCocoa. When I define actionForLayer_forKey_ method in my view class as a delegate of CALayer class, the following exception is thrown. RuntimeError: Ruby object `#<TestView:0x227388 class='TestView' id=0x53e140>' doesn't respond to the ObjC selector `actionForLayer:forKey:', the method either doesn't exist or is private It seems like RubyCocoa is actually finding the method because if I omit the method, the program runs happily. Also when I call instanceRespondToSelector from Ruby side, it returns true, although I am not sure if this test is meaningful. The other clue is that EXC_BAD_ACCESS is occasionally thrown, so the RuntimeError above might be a just spurious of the EXC_BAD_ACCESS. I am using RubyCocoa version 0.13.2 on OSX 10.5.7. The following is the test code i am using: Thanks Kei require 'osx/cocoa' OSX.require_framework '/System/Library/Frameworks/ ApplicationServices.framework/Versions/Current/Frameworks/ ImageIO.framework' OSX.require_framework 'QuartzCore' class TestView < OSX::NSView include OSX def initWithFrame(frame) super_initWithFrame(frame) return self end def drawRect(rect) end def actionForLayer_forKey_(layer, key) return nil; end def awakeFromNib thelayer = CALayer.layer setLayer thelayer setWantsLayer true thelayer.backgroundColor = black puts "rubycocoa version #{OSX::RUBYCOCOA_VERSION}" puts "instanceRespondTo: #{TestView.instancesRespondToSelector :actionForLayer_forKey_}" puts ("respond_to? #{self.respond_to? :actionForLayer_forKey_}") thelayer.delegate = self thelayer.opacity = 0.5 end private def black values = [0.0, 0.0, 0.0, 1.0] CGColorCreate(genericRGBSpace, values) end def genericRGBSpace CGColorSpaceCreateWithName KCGColorSpaceGenericRGB end end |