[MacRuby] #1148: Procs used for Cocoa callbacks are being given class objects instance of the instance of the class
#1148: Procs used for Cocoa callbacks are being given class objects instance of the instance of the class ------------------------------------+--------------------------------------- Reporter: mrada@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ------------------------------------+--------------------------------------- When I try to use a proc for a notification callback instead of a method, when the callback is made I am given the class object instead of the instance of the object. This example should work, but will not because when callback is called, it will be given the NSDictionary class constant instead of an instance of an NSDIctionary like I was supposed to get: framework 'Cocoa' callback = Proc.new { |notif| puts notif.userInfo.inspect } workspace = NSWorkspace.sharedWorkspace workspace.notificationCenter.addObserver callback, selector:'call:', name:NSWorkspaceDidLaunchApplicationNotification, object:nil workspace.launchAppWithBundleIdentifier 'com.apple.mail', options:NSWorkspaceLaunchAsync, additionalEventParamDescriptor:nil, launchIdentifier:nil NSRunLoop.currentRunLoop.runUntilDate( Time.now + 5 ) -- Ticket URL: <http://www.macruby.org/trac/ticket/1148> MacRuby <http://macruby.org/>
#1148: Procs used for Cocoa callbacks are being given class objects instance of the instance of the class ------------------------------------+--------------------------------------- Reporter: mrada@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ------------------------------------+--------------------------------------- Comment(by rob@…): Try this: {{{ class Receivable < Proc def call(sender) super(sender) end end }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1148#comment:1> MacRuby <http://macruby.org/>
#1148: Procs used for Cocoa callbacks are being given class objects instance of the instance of the class ------------------------------------+--------------------------------------- Reporter: mrada@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ------------------------------------+--------------------------------------- Comment(by lsansonetti@…): The problem is that call: is a native ruby method that isn't callable from Objective-C directly. -- Ticket URL: <http://www.macruby.org/trac/ticket/1148#comment:3> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby