Have you tried to use CoreData in RubyMotion, only to get lost in the quagmire of simplistic or confusing examples, DSL's and gems? Have you been asking yourself these questions: Do I have to use XCode to create a CoreData model?; How do relationships work in code work anyway?; How do I pre-load data into my CoreData store?; What is an NSFetchedResultsController, and why do I need one?
We'll delve into each of these questions, and review the surprisingly simple, elegant solutions that RubyMotion can provide.
7. The Story
• To rewrite a (mobile) web application
(WIMBY) as an iOS application
• Using RubyMotion
• WIMBY = Wells In My Back Yard
Monday, 21 October, 13
8. The Challenges
• LOTS of data
• On a Map
• In a list (table view)
• Filtering by location
Monday, 21 October, 13
12. 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?
Monday, 21 October, 13
13. 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
Monday, 21 October, 13
14. It’s not as scary as it looks
Monday, 21 October, 13
15. What?
• Models (entities) in code
• Relationships in code
• Loading data
• Optimization
Monday, 21 October, 13
28. Overly simplistic
• Doesn’t work with multiple models with
relationships
• You need a reference to an entity, to define
a relationship fully
Monday, 21 October, 13
40. Relationships
• Done
• With that, you can pretty much define any
kind of model and relationship you want, in
code, no magic required.
Monday, 21 October, 13
42. iOS Core Data Basics
• Back to Ray
• http://www.raywenderlich.com/12170/coredata-tutorial-how-to-preloadimportexisting-data-updated
Monday, 21 October, 13
52. That won’t work
•
•
•
•
Monday, 21 October, 13
Read in the whole file first?!?
add, save, add, save
•
horribly inefficient for large data loads
add, add, add ...., save once
•
yah, never mind
add, add, add, save, add, add, add, save
•
better, but still fails on out-of-memory
54. 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.
Monday, 21 October, 13
63. Back to Basics (again)
• Ray sure has a lot of good material, doesn’t
he?
• http://www.raywenderlich.com/999/coredata-tutorial-for-ios-how-to-usensfetchedresultscontroller
Monday, 21 October, 13