Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS Development with Ruby using RubyMotion

iOS Development with Ruby using RubyMotion

Introduction and code demo of RubyMotion.

Video: https://vimeo.com/46380771
Discussion: http://hkdev.mobi/topics/6

Francis Chong
Hong Hong Mobile Developers Meetup #2

Francis Chong

July 25, 2012
Tweet

More Decks by Francis Chong

Other Decks in Technology

Transcript

  1. Me • Francis Chong (@siuying) • Mobile and iOS app

    developer • Ignition Soft 12年7月26日星期四
  2. handle = [[NSFileHandle alloc] initWithFileDescriptor:2] [handle fileDescriptor] # => 2

    handle = NSFileHandle.alloc.initWithFileDescriptor(2) handle.fileDescriptor # => 2 12年7月26日星期四
  3. Ruby objects implemented in ObjC • String > NSMutableString •

    Array > NSMutableArray • Hash > NSMutableDictionary • Numeric > NSNumber • Time > NSDate 12年7月26日星期四
  4. def iterate(ary) ary.each { |x| puts x } end iterate

    [42] iterate NSArray.arrayWithObject(42) 12年7月26日星期四
  5. struct CGPoint { CGFloat x; CGFloat y; }; typedef struct

    CGPoint CGPoint; CGPoint pt = CGPointMake(1, -1); 12年7月26日星期四
  6. pt = CGPoint.new(100, 200) 'Hello'.drawAtPoint(pt, withFont: font) # Short Hand

    'Hello'.drawAtPoint([100, 200], withFont: font) 12年7月26日星期四
  7. # Create a new pointer to the object type. error_ptr

    = Pointer.new(:object) unless data.writeToFile(path, options: mask, error: error_ptr) # De-reference the pointer. error = error_ptr[0] # Now we can use the `error' object. $stderr.puts "Error when writing data: #{error}" end 12年7月26日星期四
  8. KVO class ExampleViewController < UIViewController include BW::KVO def viewDidLoad observe(@text_field,

    :text) do |old_value, new_value| puts "Text field did changed: #{new_value}!" end end end 12年7月26日星期四
  9. Location BW::Location.get do |r| puts "From Lat #{r[:from].latitude}, Long #{r[:from].longitude}"

    puts "To Lat #{r[:to].latitude}, Long #{r[:to].longitude}" end 12年7月26日星期四
  10. def viewDidLoad UI::Layouts.setup(view) do label width: 200, height: 20, text:

    "Choose your lucky word", color: "#eee" image_view top: 50, left: 50, right: 50, image: "sample.jpg" toolbar anchors: [:bottom] end end 12年7月26日星期四