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

Core Data in RubyMotion - #inspect

Core Data in RubyMotion - #inspect

Have you tried to use CoreData in RubyMotion, only to get lost in the quagmire of simplistic or confusing examples, DSL's and gems? Let's go out and shave that herd of yaks!

Lori M Olson

May 28, 2014

More Decks by Lori M Olson

Other Decks in Programming


  1. i Develop • Ruby (mostly) • Rails • iOS (RubyMotion)

    • JRuby • Javascript (some) • jQuery • Maps/Charts • Javascript Testing
  2. i Teach • Ruby on Rails for Real Developers (RoR4Real)

    • Rails for iOS Developers (Rails4iOS) • Ladies Learning Code - Ruby Introduction
  3. i Speak • 2014 • Scottish Ruby Conference, RubyMotion #inspect

    • 2013 • RubyConf AU, NSScotland • 2012 • Confoo, RailsConf, Aloha RubyConf • 2011 • jQueryConf, Madison Ruby • 2010 • Conferencia Rails • 2009 • RailsConf
  4. Problems • RubyMotion gems/DSL’s hide a lot • Straight iOS

    Objective-C development relies on Xcode magic (hides a lot) • Complex data is complex • Large data is large • What do I do when I reach the limitations of these solutions?
  5. The Real Problem • Sometimes you just need to understand

    how to solve problems at the most basic API code level, and the abstractions (and magic) just get in the way
  6. Models in Code • Hey, isn’t there a sample app

    for that? • Locations • https://github.com/HipByte/ RubyMotionSamples/tree/master/ios/ Locations • MVCS pattern
  7. Overly simplistic • Doesn’t work with multiple models with relationships

    • You need a reference to an entity, to define a relationship fully
  8. Solution • Define your entities. First. • Lazily! define your

    entities’ properties • properties = (attributes and relationships)
  9. Relationships • Done • With that, you can pretty much

    define any kind of model and relationship you want, in code, no magic required.
  10. iOS Core Data Basics • Back to Ray • http://www.raywenderlich.com/12170/core-

    data-tutorial-how-to-preloadimport- existing-data-updated
  11. Back to Core Data Basics • Thankfully, Ray figured that

    out. • Updated the tutorial to operate as an OS X (console) app. • RubyMotion can do that, too.
  12. Back to Basics (again) • Ray sure has a lot

    of good material, doesn’t he? • http://www.raywenderlich.com/999/core- data-tutorial-for-ios-how-to-use- nsfetchedresultscontroller
  13. In Summary • Create models in code • Create relationships

    between models in code • Pre-loading data • LOTS of data • Efficiently displaying data
  14. Core Data in Motion • It’s an ebook! • Almost

    finished! • http://coredatainmotion.com
  15. That’s All, Folks! • Code: 
 https://github.com/wndxlori/WNDXRubyMotion/ tree/master/FailedBankCD • Questions?

    Comments? • @wndxlori • [email protected] • http://www.linkedin.com/in/loriolson • http://www.wndx.com