MobileRuby:使用Ruby開發iOS應用的輕量級架構

來源:互聯網
上載者:User

該項目由Yuichiro MASUI發起,此人為Appcelerator工作。Appcelerator是一家提供移動平台開發架構的公司,其Titanium開發架構允許開發人員使用自己熟悉的語言來開發行動裝置 App。

MobiRuby基於mruby(輕量級的Ruby語言實現,可使用解釋模式運行Ruby代碼並在虛擬機器中執行)構建。Yuichiro MASUI希望通過該架構,使Ruby能夠替代Objective-C/C/Java語言來開發行動裝置 App,就像Lua或Mono一樣。

目前,該項目只有一個程式碼範例和,Yuichiro稱,首個版本將在未來幾個月內發布,將基於Apache 2.0許可協議。

MobiRuby樣本:

Ruby代碼:

 
  1. # UIAlertView demo  
  2. def _S(str)  
  3.     NSString._stringWithUTF8String(str)  
  4. end 
  5. class MyAlertView < Mobi::Cocoa::UIAlertView  
  6.     define :void, :didPresentAlertView, :id do 
  7.         p "MyAlertView::didPresentAlertView" 
  8.     end 
  9.     define :void, :alertView, :id, :clickedButtonAtIndex, :int do |me, index|  
  10.         if index == 1  
  11.             app = UIApplication._sharedApplication  
  12.             url = NSURL._URLWithString(_S("http://mobiruby.org"))  
  13.             app._openURL url  
  14.         end 
  15.     end 
  16. end 
  17. alert = MyAlertView._alloc.  
  18.     _initWithTitle _S("Hello"),  
  19.     :message, _S("I'm MobiRuby"),  
  20.     :delegate, nil,  
  21.     :cancelButtonTitle, _S("I know!"),  
  22.     :otherButtonTitles, _S("What's?"), nil 

運行結果:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.