• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Newbie question: Cocoa threads within RubyCocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie question: Cocoa threads within RubyCocoa


  • Subject: Newbie question: Cocoa threads within RubyCocoa
  • From: Arcadio Rubio GarcĂ­a <email@hidden>
  • Date: Sun, 5 Apr 2009 12:00:36 +0200

Hi all,

I'm trying to build a simple Cocoa GUI that acts as an observer to my Ruby text application and reports progress in a window (with a progress bar, etc).

I'm using RubyCocoa for creating the GUI, but I guess anyone who does not know Ruby or RubyCocoa might be still able to answer my question.

My problem is that I need to run the following GUI in a separate thread and be able to send messages to it from my main app.

Can anyone point how to do this? I've tried wrapping the app instantiation in a NSObject and doing NSThread.detachNewThreadSelector_toTarget_withObject(:run, runner, nil) to it, but the window does not appear.

Thanks.

--------------------------------

require 'osx/cocoa'
include OSX


class AppDelegate < NSObject
def init
frame = [200.0, 300.0, 250.0, 100.0]
@win = NSWindow.alloc.initWithContentRect_styleMask_backing_defer(frame,
15, 2, 0)
@win.setTitle 'Test'
@win.setLevel 0
@bar = NSProgressIndicator.alloc.initWithFrame [10.0, 10.0, 80.0, 80.0]
@win.contentView.addSubview(@bar)
@bar.setIndeterminate(false)
@win.display
@win.orderFrontRegardless
end


  def step
    @bar.incrementBy(20)
  end
end


app = NSApplication.sharedApplication app.setDelegate(AppDelegate.alloc.init) app.run _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: NSString and decoding HTML Entities
  • Next by Date: Unable to save file in Document-Based Application
  • Previous by thread: Re: Puzzling run loop/autorelease pool question
  • Next by thread: Unable to save file in Document-Based Application
  • Index(es):
    • Date
    • Thread