There is a nice and simple tutorial that can be found towards the end of this page at the MacRuby site. I gave it a try but also wanted to test the way that MacRuby can seamlessly convert to and from Cocoa strings without conversion.
In the following screencast I create a simple MacRuby application that first goes through the tutorial on the MacRuby site. This tutorial simply outputs a line to the console when a button is clicked. I then add two text fields and change the action of the button to take the text from the input field and output it with some added text to the output field.
MacRuby Tutorial (4 minutes and 4 seconds, 20.5MB)
My voice is a bit off so I put some simple commentary as subtitles rather than adding a voiceover.
You can also download the XCode project created by this screencast:
The only real code by the end of the screen cast is the code for the controller class, which is:
class MyController < NSWindowController ib_outlet :button, :inputfield, :outputfield ib_action :clicked do |sender| @outputfield.stringValue="You entered: "+@inputfield.stringValue end end
UPDATE: Got some recommendations from lrz including changing setStringValue to simply StringValue. May redo this screencast and also use fixed rather than moving screen. I’m still new to the screencast world. I’ll figure things out.
UPDATE: I have completely redone the screencast and added a note at the end showing an easier way of changing the string value of a text field. Instead of setStringValue, you can use stringValue= as in the code above. The original line is below:
@outputfield.setStringValue("You entered: "+@inputfield.stringValue)
UPDATE: One more error pointed out by lrz: in the added note at the end of the tutorial I used “StringValue=” instead of setStringValue but this should be “stringValue” with a small s. I have updated this in the code, the above posting, and the screencast.