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

RubyMotion - Geneva.rb

RubyMotion - Geneva.rb

Presentation of RubyMotion to some fellow rubyists.
Keynote download : http://cl.ly/N3XE

Frederic Jacobs

February 20, 2013
Tweet

More Decks by Frederic Jacobs

Other Decks in Technology

Transcript

  1. by @FredericJacobs RubyMotion

  2. Getting the bias out of the way

  3. iOS Developer

  4. from an Objective-C Developer Perspective RubyMotion

  5. Requirements

  6. Requirements

  7. Requirements

  8. Requirements

  9. Requirements

  10. What is RubyMotion not ?

  11. What is RubyMotion ?

  12. iOS SDK Foundation Framework Objective-C Runtime Objective-C

  13. iOS SDK Foundation Framework Objective-C Runtime RubyMotion Objective-C

  14. FAST

  15. Wait, how can that possibly work ?

  16. The Man @lrz Laurent Sansonetti

  17. The Man @lrz MacRuby 7 years of experience at Apple

    Mac OS X IDA Pro GNOME Laurent Sansonetti RubyCocoa RubyMotion iLife
  18. Smalltalk

  19. Smalltalk Objective-C Ruby(Motion)

  20. Mixins Objective-C • No mixins available in ObjC language •

    Runtime Implementation : class_addMethod(Class cls, SEL name, IMP imp, const char *types); Ruby(Motion) module CapitalNames def capitalized_name name.upcase end end class User include CapitalNames def initialize name @name = name end def name @name end end
  21. Open-Classes Objective-C • Objective-C is using “Categories” •Implementation : @implementation

    NSNumber (TimeDiff) - (NSNumber *)days { return [NSNumber numberWithInteger:([self intValue] * 24 * 60 * 60)]; } - (NSDate *)ago { return [NSDate dateWithTimeIntervalSinceNow:[self intValue]]; } @end Ruby(Motion) class Fixnum def days self * 24 * 60 * 60 end def ago Time.now - self end end
  22. So why RubyMotion ?

  23. And Ruby loves iOS You Love Ruby Well, now Ruby

    loves iOS
  24. Ruby way of doing things Objective-C NSFileManager *mgr = [NSFileManager

    defaultManager]; NSArray *paths =[mgr contentsOfDirectoryAtPath:@"/etc" error:nil]; [paths enumerateObjectsUsingBlock:^(id obj, ...) { NSLog(@"%@", obj); }]; Ruby(Motion) Dir["/etc"].each do |name| puts name end
  25. Keep your tools

  26. Command Line Debugging

  27. Documentation

  28. But how to deal with Objective-C weirdness ? Objective-C [string

    drawAtPoint:point withFont:font]; Ruby(Motion) string.drawAtPoint(point, withFont:font)
  29. Demo Time

  30. You’re not alone Wrappers Especially BubbleWrap

  31. @FredericJacobs Email : frederic.jacobs@mac.com GitHub : github.com/FredericJacobs Slides : speakerdeck.com/FredericJacobs