problem about macruby-Collection of common programming errors


  • Jan Dudek
    ruby osx macruby fsevents
    I’m working on GUI app in MacRuby and I need to use FSEvents. I’m registering a couple of streams for different directories. Changes in any of those directories result in running a callback, but there’s a big issue: no matter which directory changes, the last registered callback is executed.Below is isolated test script:framework ‘Cocoa’ framework ‘CoreServices’class Monitordef initialize(dir)@dir = direnddef start(&block)callback = Proc.new do |stream, context, count, paths, flags, ids|p @d

  • kiamlaluno
    objective-c cocoa macruby pyobjc ruby-cocoa
    Years ago wanting to write Mac software and having loads of experience with Java WebObjects I tried the java bridge but decided to bite the bullet and learn Objective-C (fortunately since I would have hated having my software deprecated with the bridge). Later I fooled around with RubyCocoa. I learnt Ruby (found it interesting indeed), but found out the hard way that the bridge was far from mature or stable and at the end I ended porting the code back to Objective-C.Since years have passed, I’m

  • goofrider
    osx cocoa itunes macruby scripting-bridge
    I’m trying to populate an NSPopUpButton with an array of ITunesPlaylist objects. I got the NSArrayController bind to NSPopUpButtonapp = SBApplication.applicationWithBundleIdentifier(“com.apple.iTunes”) playlists = app.sources.objectWithName(“Library”).userPlaylistsmyArrayController.setContent playlistsAll the playlists will appear in the NSPopUpButton but they all have names with <ITunesUserPlaylist:0x4018a5000: iTunesUserPlaylist 0 of iTunes Source “Library” of Application “iTunes” (51822)&g

  • Antony Perkov
    exception-handling macruby
    Assuming you have a MacRuby application with an NSExceptionHandler delegate hooked up like so:exception_handler = NSExceptionHandler.defaultExceptionHandler exception_handler.exceptionHandlingMask = NSLogAndHandleEveryExceptionMask exception_handler.delegate = my_delegateYour delegate can retrieve an array containing call stack addresses easily enough:def exceptionHandler(sender, shouldLogException:exception, mask:aMask)addresses = exception.userInfo[NSStackTraceKey]return false endIs it possibl

  • Colin Dean
    cocoa pipe stdout stdin macruby
    I’m attempting to execute a command, feed data to its stdin, and read from its stdout. I’ve tried using Ruby’s Open3#popen3 as well as NSTask, exposed via MacRuby. The source for the program I’m writing is available here. I’m doing this in Xcode and MacRuby.Here’s some select code:The entry point, just simply allowing me to easily switch between the two methods.def do_gpg_cmd cmddo_gpg_cmd_nstask cmd endThe ruby way, using Open3#popen3.def do_gpg_cmd_ruby cmdgpg = “#{@gpg_path} –no-tty “cmd_out

  • meagar
    javascript objective-c webview macruby
    I have a new MacRuby application. I’m trying to call a MacRuby method from JavaScript loaded in a webView within the application.The Calling Objective-C Methods From JavaScript tutorial shows how to add a key to the webScriptObject that’s value is an Objective-C object. Thus you can call Obj-C methods from JavaScript.Unfortunately this does not work with MacRuby classes/methods. Below is a shorten version of my WebView’s loadDelegate:class WebLoadDelegateattr_accessor :objc_bridge, :mr_bridgedef

  • MichaelC
    ruby xcode gem ffi macruby
    I need to use a gem from MacRuby (ruby-keychain), and this gem uses FFI.But it looks like FFI is not working from MacRuby.Using the irb console, it works fine :cobalt:~ charbon$ irb irb(main):001:0> require ‘ffi’ => true irb(main):002:0> module MyLib irb(main):003:1> extend FFI::Library irb(main):004:1> ffi_lib ‘c’ irb(main):005:1> attach_function :puts, [ :string ], :int irb(main):006:1> end => #<FFI::Function address=0x007fff8be0197b> irb(main):007:0> MyL

  • Barry
    macruby
    I am starting to write a MacRuby app. I installed some gems which i am interested in using. I get an error in xmlbase when trying to run. /Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/Gems/1.9.2/gems/builder-3.0.0/lib/builder/xmlbase.rb:in _indent’: undefined method*’ for nil:NilClass (NoMethodError)I am using the 0.10 version of the framework. I downloaded the latest daily version to see if its been fixed but when my app runs its still calling the old 0.10 version. How do i g

  • Craig Williams
    ruby macruby
    This works in Objective-C but in MacRuby I cannot find a way to access the properties of the Boxed object that is returned.MacRuby Version 0.7 -> latest build as of 2010-05-02 OS -> 10.6.3Objective-C Version:CLLocation *loc = [[CLLocation alloc] initWithLatitude:38.0 longitude:-122.0]; NSLog(@”Lat: %.2f”, loc.coordinate.latitude); NSLog(@”Long: %.2f”, loc.coordinate.longitude); [loc release]; // Results: // 2010-04-30 16:48:55.568 OCCoreLocationTest[70030:a0f] Lat: 38.00 // 2010-04-30 16:48:55.5

  • jwfearn
    ruby jruby macruby rubinius
    The method I know of to detect the Ruby implementation (e.g., MRI, JRuby, Rubinius, etc.) at run time is to check the global constant RUBY_ENGINE:$ ruby -e ‘puts RUBY_ENGINE’ rubyWhat’s a reasonably comprehensive list of known Ruby implementations and their corresponding values for RUBY_ENGINE?

  • bmorgan
    macruby
    As a MacRuby beginner I am working through this tutorial, and want to add a drop-down sheet to warn when the user tries to delete an entry from the app.Following the code here, which in Obj-C is- (IBAction)deleteRecord:(id)sender {NSString *title = @”Warning!”;NSString *defaultButton = @”Delete”;NSString *alternateButton = @”Don’t Delete”;NSString *otherButton = nil;NSString *message = @”Are you sure you want to delete the selected record(s)?”;if ( [tableView numberOfSelectedRows] == 0 )return;

Web site is in building

I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money