6. What’s the point of this
talk?
• I decided to try to learn RubyMotion
without first learning traditional iOS
development in XCode and Objective-C.
• If you’re starting out, you might be
wondering how to start.
• A mix of experience report and tips-and-
tricks
• This is also just about learning something
new.
7. A way to learn
• Understand enough to make something,
however messy
• Make it smaller
• Introduce third-party code
• Start over
10. Final Version system
• Keep a list of tasks
• Mark the first item with a dot
• Go down the list until you find an item you want
to do before the closest dotted item above
• Repeat until you reach the end of the list
• Then attend to the tasks in bottom-up order
• Delete completed items, and otherwise move
items to the end when you stop working on them
• When nothing is left dotted, start dotting at the
top again
11. Example
Write slides for meetup
Prepare TPS report
Get a haircut
Contemplate my mortality
Eat some ice cream
12. Example
• Write slides for meetup
Prepare TPS report
• Get a haircut
Contemplate my mortality
• Eat some ice cream
13. Example
• Write slides for meetup
Prepare TPS report
• Get a haircut
Contemplate my mortality
• Eat some ice cream
19. class TaskImageController < UIImagePickerController
def viewDidLoad
self.sourceType = has_camera? ? UIImagePickerControllerSourceTypeCamera :
UIImagePickerControllerSourceTypePhotoLibrary
self.mediaTypes = [KUTTypeImage]
self.delegate = self
self.allowsImageEditing = false
end
def imagePickerControllerDidCancel(picker)
presentingViewController.dismissModalViewControllerAnimated(true)
end
def imagePickerController(picker, didFinishPickingMediaWithInfo:info)
mediaType = info[UIImagePickerControllerMediaType]
TaskList.shared.add_photo_task(info[UIImagePickerControllerOriginalImage])
presentingViewController.dismissModalViewControllerAnimated(true)
end
def has_camera?
UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceTypeCamera)
end
end
20. class TaskList
TaskListChangedNotification = 'TaskListChanged'
def self.shared
@instance ||= TaskList.new
end
def all_tasks
TaskStore.shared.all_tasks
end
def add_text_task(text)
make_change do
return if text == ''
TaskStore.shared.create_task do |task|
task.date_moved = NSDate.date
task.text = text
task.dotted = false
task.active = false
task.photo = false
end
end
end
def add_photo_task(image)
make_change do
TaskStore.shared.create_task do |task|
task.date_moved = NSDate.date
task.dotted = false
task.active = false
task.photo = true
task.photo_uuid = BubbleWrap.create_uuid
scaled_image = ImageStore.saveImage(image, forTask:task)
21. What is RubyMotion?
• Ruby re-implemented on top of iOS
• Ruby statically compiled
• Terminal-based toolchain
• Keep using your favorite editor
• Amazing community
(slide stolen from Laurent Sansonetti talk “RubyMotion: Ruby in your pocket” by Laurent Sansonett
via http://youtu.be/gG9GTUTI9ys)
22. How is it different from
Ruby?
• added named arguments
• no eval
• no define_method
• no require
• most gems don’t work out of the box
25. Pierre Menard, Author
of the Quixote
http://www.coldbacon.com/writing/borges-quixote.html
26. He did not want to compose another Quixote —which is easy— but the Quixote
itself. Needless to say, he never contemplated a mechanical transcription of the
original; he did not propose to copy it. His admirable intention was to produce a
few pages which would coincide—word for word and line for line—with those of
Miguel de Cervantes.
[...]
The first method he conceived was relatively simple. Know Spanish well, recover
the Catholic faith, fight against the Moors or the Turk, forget the history of Europe
between the years 1602 and 1918, be Miguel de Cervantes. Pierre Menard studied
this procedure (I know he attained a fairly accurate command of seventeenth-
century Spanish) but discarded it as too easy. Rather as impossible! my reader will
say. Granted, but the undertaking was impossible from the very beginning and of all
the impossible ways of carrying it out, this was the least interesting. To be, in the
twentieth century, a popular novelist of the seventeenth seemed to him a
diminution. To be, in some way, Cervantes and reach the Quixote seemed less
arduous to him—and, consequently, less interesting—than to go on being Pierre
Menard and reach the Quixote through the experiences of Pierre Menard.
45. sugarcube
a small library of extensions to the Ruby built-in classes that make it
a little easier - and hopefully more “rubyesque” - to work in Cocoa.
https://github.com/rubymotion/sugarcube