Projects

Ticket #550 (closed defect: fixed)

Opened 2 years ago

Last modified 22 months ago

TypeError: unrecognized runtime type when using NSThread.alloc.initWithTarget

Reported by: mattaimonetti@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.6
Component: MacRuby Keywords:
Cc:

Description

>> framework 'Foundation'
=> true
>> thread = NSThread.alloc.initWithTarget(self, selector:'sleep:', object:'5')
TypeError: unrecognized runtime type `'

Doing:

framework 'Foundation'

class ExpensiveCalculation
  def start(to_process)
    puts "processing on a separate thread"
    exit
  end
end

calculation = ExpensiveCalculation.new
thread = NSThread.alloc.initWithTarget(calculation, selector:'start:', object:'dummy_obj')
thread.start

Works fine tho.

Change History

Changed 22 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from MacRuby 0.5 to MacRuby 0.6

The problem was when re-typing the method. The problem should be fixed in r3955.

$ cat t2.rb 
framework 'Foundation'

class Foo
  def test(obj)
    p "inside test..."
    sleep 2
  end
end

o = Foo.new
t = NSThread.alloc.initWithTarget(o, selector: :"test:", object: nil)
t.start

p "wait..."
while !t.isFinished; end
p "finished"

$ ./miniruby t2.rb 
"wait...""inside test..."

"finished"
$ 
Note: See TracTickets for help on using tickets.