A FRAMEWORK • RubyMotion is a toolchain • Cocoa / Cocoa Touch is our framework • It’s lower level but much larger than Rails • This means more reusable objects • We also fight against our framework less • It’s better to treat RubyMotion development like you’re creating a “plain” Ruby app
WE STILL HAVE TOOLS • ProMotion • motion-prime • RubyMotionQuery • BubbleWrap • Formotion • Teacup • motion-layout • Sugarcube UnderOS is also a great tool for making iOS more like the web
WE STILL HAVE TOOLS • ProMotion • motion-prime • RubyMotionQuery • BubbleWrap • Formotion • Teacup • motion-layout • Sugarcube UnderOS is also a great tool for making iOS more like the web A little bird told me there is some great new tools coming soon
They serve the same purpose • View Controllers handle one screen • Rails controllers are “stateless” • RubyMotion controllers handle an entire lifecycle
DIFFERENCE • A stateful object to work with • It has lifecycle methods to hook into • Find comfort and rejoice in lots of classes instead of lots of methods • You can see these differences in most areas, not just controllers
loadView! ! # set up your view! end! ! def viewDidLoad! ! # extra changes to! ! # your view! end! ! def viewWillAppear(a)! ! # data + view! end! ! def viewDidDisappear(a)! ! # let go of things! end
Lots of subclassing, take advantage of framework classes • Kept clean and reusable with the Composite pattern • It’s worth learning Auto Layout for easier reuse • Use delegates and data sources for talking to the controller • Controller owns the view, it can talk to the view however
By subclassing we utilise the framework classes • Views are focused on displaying things • We can implement the design in our subclasses • A simple public API for updating can be all we need
• A hierarchy like the HTML DOM • The system uses this for an event responder chain • Make each part of your screen’s UI a subview • Keep all styling in each class • We can take advantage of it for trickling down data changes • Focus on reuse
< UILabel! ! def initialize! ! ! # style the view and set up the layout! ! end! ! ! def update(data = {})! ! ! # find the data it cares about and update display! ! end! end! THE TASK APP’S VIEW
1. MotionInMotion Episodes 2 & 3 2. My upcoming book “RubyMotion for Rails Developers” 3. WWDC 2012 for Auto Layout 4. Clay Allsopp’s book “RubyMotion” from PragProg