最終更新:2013-01-05 (土) 10:42:17 (1720d)  

MobiRuby はてなブックマークを見る
Top / MobiRuby

Ruby + iOS = Super awesome!

http://mobiruby.org/

# UIAlertView demo
class Cocoa::MyAlertView < Cocoa::UIAlertView
    define C::Void, :didPresentAlertView, Cocoa::Object do
        p "MyAlertView::didPresentAlertView"
    end

    define C::Void, :alertView, Cocoa::Object, :clickedButtonAtIndex, C::Int do |me, index|
        if index.to_i == 1
            app = Cocoa::UIApplication._sharedApplication
            url = Cocoa::NSURL._URLWithString("http://mobiruby.org")
            app._openURL url
        end
    end
end

alert = Cocoa::MyAlertView._alloc._initWithTitle "Hello",
  :message, "I am MobiRuby",
  :delegate, nil,
  :cancelButtonTitle, "I know!",
  :otherButtonTitles, "What's?", nil
alert._setDelegate alert
alert._show