{"id":7027,"date":"2014-05-17T00:22:08","date_gmt":"2014-05-17T00:22:08","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/problem-about-macruby-collection-of-common-programming-errors\/"},"modified":"2014-05-17T00:22:08","modified_gmt":"2014-05-17T00:22:08","slug":"problem-about-macruby-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/problem-about-macruby-collection-of-common-programming-errors\/","title":{"rendered":"problem about macruby-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a6d2a8c0851b37a46827e3b23a84e4c0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJan Dudek<br \/>\nruby osx macruby fsevents<br \/>\nI&#8217;m working on GUI app in MacRuby and I need to use FSEvents. I&#8217;m registering a couple of streams for different directories. Changes in any of those directories result in running a callback, but there&#8217;s a big issue: no matter which directory changes, the last registered callback is executed.Below is isolated test script:framework &#8216;Cocoa&#8217; framework &#8216;CoreServices&#8217;class Monitordef initialize(dir)@dir = direnddef start(&amp;block)callback = Proc.new do |stream, context, count, paths, flags, ids|p @d<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f5ef1b81e1aeb3b921a3034d460ce6af?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkiamlaluno<br \/>\nobjective-c cocoa macruby pyobjc ruby-cocoa<br \/>\nYears 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&#8217;m<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6a87955739cf9946e15bdd9a202248f1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngoofrider<br \/>\nosx cocoa itunes macruby scripting-bridge<br \/>\nI&#8217;m trying to populate an NSPopUpButton with an array of ITunesPlaylist objects. I got the NSArrayController bind to NSPopUpButtonapp = SBApplication.applicationWithBundleIdentifier(&#8220;com.apple.iTunes&#8221;) playlists = app.sources.objectWithName(&#8220;Library&#8221;).userPlaylistsmyArrayController.setContent playlistsAll the playlists will appear in the NSPopUpButton but they all have names with &lt;ITunesUserPlaylist:0x4018a5000: iTunesUserPlaylist 0 of iTunes Source &#8220;Library&#8221; of Application &#8220;iTunes&#8221; (51822)&amp;g<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5c1913018677201ac82eeec46fd13706?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAntony Perkov<br \/>\nexception-handling macruby<br \/>\nAssuming 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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e3c791e8e5da39bf88b09dfb089de01b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nColin Dean<br \/>\ncocoa pipe stdout stdin macruby<br \/>\nI&#8217;m attempting to execute a command, feed data to its stdin, and read from its stdout. I&#8217;ve tried using Ruby&#8217;s Open3#popen3 as well as NSTask, exposed via MacRuby. The source for the program I&#8217;m writing is available here. I&#8217;m doing this in Xcode and MacRuby.Here&#8217;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 = &#8220;#{@gpg_path} &#8211;no-tty &#8220;cmd_out<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c032a0e8e40dd79b715420e4c5d03b00?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmeagar<br \/>\njavascript objective-c webview macruby<br \/>\nI have a new MacRuby application. I&#8217;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&#8217;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&#8217;s loadDelegate:class WebLoadDelegateattr_accessor :objc_bridge, :mr_bridgedef<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/49a601fdce8c0240a4a8c3df1def5120?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMichaelC<br \/>\nruby xcode gem ffi macruby<br \/>\nI 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&gt; require &#8216;ffi&#8217; =&gt; true irb(main):002:0&gt; module MyLib irb(main):003:1&gt; extend FFI::Library irb(main):004:1&gt; ffi_lib &#8216;c&#8217; irb(main):005:1&gt; attach_function :puts, [ :string ], :int irb(main):006:1&gt; end =&gt; #&lt;FFI::Function address=0x007fff8be0197b&gt; irb(main):007:0&gt; MyL<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0d6ced540f824543c82b8ed7773c9b3c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBarry<br \/>\nmacruby<br \/>\nI 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&#8217;: undefined method*&#8217; 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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e523ef898741d5d1f0a4efd6e21b7916?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCraig Williams<br \/>\nruby macruby<br \/>\nThis 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 -&gt; latest build as of 2010-05-02 OS -&gt; 10.6.3Objective-C Version:CLLocation *loc = [[CLLocation alloc] initWithLatitude:38.0 longitude:-122.0]; NSLog(@&#8221;Lat: %.2f&#8221;, loc.coordinate.latitude); NSLog(@&#8221;Long: %.2f&#8221;, 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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/19e0056ff86b3a450f9a22c183afa254?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njwfearn<br \/>\nruby jruby macruby rubinius<br \/>\nThe 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 &#8216;puts RUBY_ENGINE&#8217; rubyWhat&#8217;s a reasonably comprehensive list of known Ruby implementations and their corresponding values for RUBY_ENGINE?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d4f924c0b2c5976be992664f0a447f8b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbmorgan<br \/>\nmacruby<br \/>\nAs 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 = @&#8221;Warning!&#8221;;NSString *defaultButton = @&#8221;Delete&#8221;;NSString *alternateButton = @&#8221;Don&#8217;t Delete&#8221;;NSString *otherButton = nil;NSString *message = @&#8221;Are you sure you want to delete the selected record(s)?&#8221;;if ( [tableView numberOfSelectedRows] == 0 )return;<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n<p>I discovery a place to host code\u3001demo\u3001 blog and websites.<br \/>\nSite access is fast but not money<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.m5zn.com\/newuploads\/2014\/01\/30\/jpg\/e7da807964b1fff.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jan Dudek ruby osx macruby fsevents I&#8217;m working on GUI app in MacRuby and I need to use FSEvents. I&#8217;m registering a couple of streams for different directories. Changes in any of those directories result in running a callback, but there&#8217;s a big issue: no matter which directory changes, the last registered callback is executed.Below [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7027","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7027"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7027\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}