Monthly Archives: March 2014

Issue #20

New and Improved Motion Meetup

Gant and Matt are changing the format of Motion Meetup from an interview to a panel discussion plus the occasional interview. Here is the new panel:


Gant LabordeMatt GarrisonMark Rickert, and me

I’m sure the first meetup will be a work in progress, but we’re all trying to bring some RubyMotion information and entertainment to you each month.

It’s going to be at 3PM PST today, or you can catch it later. The special guest is Jack Watson-Hamblin. Please join us. The Google+ page is here.

If you missed the last issue, you can find it here: issue #19

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts

Mar 24th, 2014 – “screencast – NSFetchedResultsController” by Jack Watson-Hamblin

Mar 24th, 2014 – “RubyMotion is Sexy” by Matt Brewer

Mar 23th, 2014 – “How to implement global hotkeys in your Mac OS X app using RubyMotion” by Elliott Draper

Mar 22th, 2014 – “How you doin’ RubyMotion” by Murtuza Kutub

Mar 21th, 2014 – “RubyMotion is not Rails” by Matt Brewer

Mar 21th, 2014 – “RubyMotion Preprocessor Code” by Jack Watson-Hamblin

Mar 20th, 2014 – “RubyMation, A Series of Animation Libraries for RubyMotion” by Multunus

Mar 10th, 2014 – “gem – yapper – RubyMotion ORM for YapDatabase” by Kareem Kouddous

Who knows – “Testing the presence of a UIAlertView in RubyMotion on iOS7” by Jaune Sarmiento

Motion Meetup Announcement

Today at 3pm PST, with a new panel of hosts and special guest Jack Watson-Hamblin

Please join us, or watch it later. The Google+ page is here

RubyMotion Tip of the Week

Enable User Interaction

You may have noticed that gestures don’t work on images (such as tap). They actually do, but userInteractionEnabled is false on UIImageViews by default. You simply need to turn on user interactions. The same is true for UILabel.

my_view = UIImageView.alloc.initWithFrame([[100,100],[100,100]])
my_view.userInteractionEnabled = true
recognizer = UITapGestureRecognizer.alloc.initWithTarget(self, action: 'some_method')

Other types of views, such as UIButtons, default to true, thus why gestures work for them.

If you use RMQ, you can do this:

rmq.append(UIImageView, :style_name).enable_interaction.on(:tap) do |sender|
  # do something

iOS Marketing Tip of the Week by Mark Rickert

Internationalization (i18n) and localization (l10n) of your apps are a great way to reach a wider audience. The App Store is a global marketplace, so why not try and cater to as many as possible?

You may be asking, “What’s the difference between i18n and l10n?” I18n is the process of making your app localizeable. Theoretically you should only have to do this once. L10n is done multiple times, once for each locale you want to support.

The i18n process should include things like:

  1. Abstracting all text into an external file located in your /resources folder. Sugarcube has some abstractions that make this really easy.
  2. Making sure things like dates, times, currency values, sort order, etc. are formatted according to the user’sNSLocale.currentLocale
  3. Make sure to test languages other than your native tongue to see how they look. German words are on average_30% longer_ than English! Ensuring that very long text strings will fit and look good without truncation might take some time. Use UILabel‘s sizeToFit method or for even easier global styling, use RMQ’s UILabelStyler,

    Once you’ve internationalized your app, you do multiple localizations into other locales. This is mostly just string translation. You can get volunteers or use a service like PhraseApp to translate your app (who conveniently have a RubyMotion Gem).

    When you upload the new binary, Apple automatically detects the new languages your app is available in and denotes that in the left column of your app’s App Store page. I18n and l10n are certainly not easy, but the non-English speaking world will thank you for it.

CDQ News and Tips by Ken Miller

If you are using CDQ and you find that your UI sometimes pauses while your app is writing data, you might consider the popular “private writer” pattern. By default, CDQ will set up you with a single context right in the main UI thread. That’s the simplest to reason about, and is fine for many apps, so it’s the default, but if you are using a lot of data, Core Data provides a lot of flexibility. In this case, that means a special context which maintains its own captive thread, on which all writes can take place. By inserting this context into the chain below your main context, you can achieve perfect atomic consistency within your UI, while still deferring the actual physical writing to another thread, letting your main thread go about its business.

To use the pattern, instead of running cdq.setup as usual, run this: 
# private writer 
# UI context

This pushes a private queue context onto the stack first, then a main context on top of it, which is what your code will interact with directly. That’s all you have to change! will correctly save both contexts in turn.

I’ll talk about even more advanced context arrangements in a future tip, but until then, here’s some background reading (which should also illustrate what CDQ is saving you from — see the section on Asynchronous Saving):

Multi-Context Core Data

Help support the Dispatch and signup over at MotionInMotion

MotionInMotion releases a new RubyMotion screencast each week. Here are some examples:

  • Episode 12 – Application URLs
  • Episode 11 – RMQ
  • Episode 10 – Teacup
  • Episode 9 – ProMotion + Formotion
  • Episode 7 – Working with the Camera

Sign up, it’s only $9AUD/month!

One more thing

The great folks over at JetBrains are sponsoring the RubyMotion #inspect Conference, send them your love.


If you have any tips, blog posts, or want to sponsor this newsletter, please send emails to

Issue #19

Happy Coding

I’m serious about my catch-phrase “happy coding”. Many of us get paid well to play-around with fun stuff all day. Sure it’s frustrating, and can be stressful, but so is digging coal out of a hole in the ground.

This really hit home one day, circa 1995. At that time I installed and fixed Novell servers (yes, I’m that old, shh). I was fixing a problem at an MRI facility. One of the doctors was talking to me, he was the cliche movie doctor: 30 years old, a good looking guy, fit, and smart. He made four or five times more than I did (those were different days back then – get off my lawn!). What he said stuck with me: “I wish I had your job, you get to do for a living what I do for a hobby”. I guess no one is a doctor for a hobby.

If you missed the last issue, you can find it here: issue #18

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts

Mar 25th, 2014 – “Meetup – BostonMotion 5 – RubyMotion Meetup” by BostonMotion

Mar 18th, 2014 – “Speaker Deck – iBeacons and RubyMotion” by Will Raxworthy

Mar 18th, 2014 – “RubyMotion Workflow Customizations” by Thom Parkin

Mar 17th, 2014 – “Screencast – MotionInMotion – Episode 15 – Grand Central Dispatch” by Jack Watson-Hamblin

Mar 17th, 2014 – “Truly Universal RubyMotion Apps” by Jack Watson-Hamblin

iOS Marketing Tip of the Week by Mark Rickert

Are you an iTunes Affiliate? If you write mac or iOS apps you should be! You’re losing out on an additional revenue stream if you don’t use affiliate links. Once you sign up for the program and get your affiliate code, all you have to do is append at=[your affiliate code] to any iTunes Store or Mac App Store links and you will earn a percentage of any sales for that user’s session (not just on your apps or the app you linked to, up to 24 hours)!

A great feature of the affiliate program is that it can also track campaigns. In addition to the at query parameter, you can use ct=whatever to track campaigns. I always post links to Twitter with ct=twitter so that I know how much revenue I’ve earned from people clicking my links on Twitter.

Unless you run a link-heavy website that just drives traffic to the App Stores, you won’t see a huge amount of revenue from the affiliate program. But if you advertise your apps on your website you might as well make some money off those links! You can earn 1-7% of the user’s total transaction and on average my website generates $15-$30 a month in affiliate commissions. It’s just another great way to make some extra passive income.

RubyMotion App of the Week


Updated Mar 13th, 2014 – Jukely

“Jukely matches you with concerts and friends to go with, based on your collective music tastes.”

This was the very first “App of the Week” in the Dispatch issue #1. It’s been updated and most of our readers weren’t around when issue #1 came out, so I’m digging it out of the attic. This video is awesome, watch it now!

RubyMotion Tip of the Week

Interactive app previews and design tools for your project

There are some cool tools out there that many people don’t know about. Here are a few:

  • Flinto is great if you need to share your designs
  • I really like the POP app, and I use it myself
  • I personally never got to work, but the idea is cool
  • Briefs
  • invision

RMQ News

New Version 0.5.6

  • IMPORTANT – Fixed memory leak when selecting a container view like a UITableView. It would dealloc the table, for example, but not the table cells. Thank you Michael Graff for reporting this bug
  • Added .layout to position: rmq(your_view).layout(l: 10, t: 15, w: 100, h: 20)
  • Added more UIButton styler methods – Thanks s.ross
  • Added styler for UITextField – Thanks Michael Graff
  • Added styler methods for UIScrollView – Thanks Mark Rickert
  • Fixed issue with :unknown on device orientations – Thanks s.ross
  • Updated README, added better image section, various corrections – Me (Todd Werth) and Chris Lerum
  • Documented .distribute
bundle update ruby_motion_query

Help support the Dispatch and signup over at MotionInMotion

MotionInMotion releases a new
RubyMotion screencast each week. Here are some examples:

  • Episode 12 – Application URLs
  • Episode 11 – RMQ
  • Episode 10 – Teacup
  • Episode 9 – ProMotion + Formotion
  • Episode 7 – Working with the Camera

Sign up, it’s only $9AUD/month!

One more thing

I love this line: “And I have made ~~millions~~ ~~thousands~~ hundreds…”

It’s from here.

If you have any tips, blog posts, or want to sponsor this newsletter, please send emails to

Issue #18

RubyMotion #inspect 2014 conference update

Hey RubyMotion fans, here is an update on #inspect 2014. This is the floor plan of our venue:

full-size image

The Golden Gate Room is the main room where we all will be sharing, talking, and teaching each other about RubyMotion. There is a pretty good size screen behind the stage. The ceiling is very high and the room will easily hold all of us. It has windows on three sides. On the right side it looks out over boats then to the Golden Gate Bridge. Here is a photo:


The Marina Room is where we’ll have food, drinks, and a place to hang around. It can hold upto(80) people sitting. We can also use this space for other things. If you have any ideas, let me know.

The Bay Room will be where the speakers can setup. The Foyer is a decent size, it has room for tables and such. There is also a very small kitchen if we need a place to prep food.

Outside, we get a slab of concrete with picnic benches on it (8 of them IIRC). Plus the marina with the boats is right next door:


We can serve alcohol here, which means we don’t need to travel somewhere else for our after-party. We’ll have other refreshments for those not drinking alcohol.

We’re working hard to make the conference and the after-party a safe and inclusive event. I’m personally going to make sure everyone is having fun and feeling comfortable. I’ve been to plenty of conferences where some people (the “cool kids”) seem to be having all the fun, while the rest are wondering what to do. I’m going to personally make sure that doesn’t happen here. It’s my personal mission.

If you haven’t signed up yet, I recommend you do, we’d love to see you there. If you’d really like to come but for some reason you’re having difficulties, let me know, perhaps the community can assist you.

If you missed the last issue, you can find it here: issue #17

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts

Mar 11th, 2014 – “Reflecting on RubyMotion Experiences – Part 2” by Tony Issakov

Mar 11th, 2014 – “gem – motion-weakattr – weak_attr for WeakRefs in RubyMotion” by Clay Allsopp

Mar 10th, 2014 – “screencast – Episode 14 – Five Advanced RubyMotionQuery Tips” by Jack Watson-Hamblin]

Mar 10th, 2014 – “gem – motion-momentum – RubyMotion framework for creating iOS and OS X applications the “Rails” way” by Jack Watson-Hamblin

Mar 7th, 2014 – “NSAgent – A OSX RubyMotion app to record screen videos and upload them easily. ” by Ivan Acosta-Rubio

Mar 7th, 2014 – “gem – stringify_float – Work around poor floating point support with RubyMotion” by Michael Graff

Mar 7th, 2014 – “gem – motion-gyro-image-controller – iOS (RubyMotion) Image Controller with Tilt Control” by Jerry John Jacob

Mar 7th, 2014 – “RubyMotion The “Rails” Way” by Jack Watson-Hamblin

Mar 6th, 2014 – “Adding Couchbase Lite to a RubyMotion application” by Josep

Mar 6th, 2014 – “RubyMotion on OS X – the sky is the limit (especially for Rails developers!)” by Elliott Draper

Mar 5th, 2014 – “RubyMotion: Under the hood” by Tony Issakov

Mar 5th, 2014 – “gem – motion-linear-animate – RubyMotion library for linear animations” by Jerry John Jacob

Mar 5th, 2014 – ““An introduction to RMQ” updated” by Todd Werth

Mar 4th, 2014 – “New in RubyMotion: New CLI, WeakRef Zeroing, Background Fetch Testing, Subscripting, Performance” by RubyMotion

Mar 3rd, 2014 – “Real-time web rubymotion built with Ruby on Rails and RubyMotion” by Yuki Moriyama

Mar 1st, 2014 – “atom-rubymotion – RubyMotion support in Atom” by Satoshi Ebisawa

RubyMotion News

RubyMotion 2.24

  • Fixed a regression introduced by the last build where environments running
    versions of Ruby not handling source files as unicode by default would be
    broken due to the presence of a unicode character in one of the files.

RubyMotion 2.23

  • Added support for objects conforming to the Subscripting interface
    (Objective-C Literals).
  • Fixed a bug with the `motion activate’ CLI command. Thanks to Joffrey
    Jaffeux for the patch.
  • Fixed a regression when specifying external templates to `motion create’.
  • Fixed a bug where would cause a crash when nil, true, false,
    Fixnum or Float objects were passed.
  • Fixed a bug where vendor_project' with:static’ did not reuse `:cflags’
    for the BridgeSupport generation.
  • Fixed a bug where manually created BridgeSupport metadata files were no
    longer being used by the compiler. Now if one exists in the root of the lib
    dir, that will be used instead of one in the platform-specific build dir.
  • Added temporary files that are sometimes generated by the REPL to the
    default `gitignore’ file. Thanks to Mark Rickert for the patch (pull
    request #150).
  • Added support for “value of def-expr” feature (ex. def foo; end' returns
    :foo’ symbol).
  • Fixed a bug where NSDate.distantFuture returns a wrong value.
  • Fixed a memory leak when an exception message is created.
  • Fixed a bug where the cycle detector would be activated during asynchronous
    Dispatch::Queue blocks even if ARR_CYCLES_DISABLE was set.
  • Fixed a bug where #send would freeze the app when passed a method name
    which accepts a bool if the method would be used with #send only.
  • Optimized methods converting implicitely types using #to_str etc.
  • Improved String#to_sym performance. ~40% faster.
  • Improved performance in dispatcher. ~20% faster.
  • Improved performance where allocates internal memory of String objects.
    ~10% faster.
  • Improved performance of methods where accepts Regexp object. ~20% faster.
  • Improved String literals performance. ~60% faster.
  • Improved String performance where it handles short strings. ~25% faster.
  • Improved String#{strip, rstrip, lstrip} performance. ~70% faster.
  • Improved String#{[], []=, +, =~} and Array#+ performance. ~20% faster.
  • Improved String#{==, !=} performance. ~50% faster.
  • Improved String#include? with UTF-8 strings performance. ~15% faster.
  • Improved String#{==, <=>}, NSString#== and Hash#== performance if it would
    compare other class object. ~8 times faster.
  • Improved Time#{+, -} performance. ~25% faster.
  • Improved Time#{==, !=, <, <=, >, >=} performance. ~2 times faster.
  • Improved Time#+ with float performance. ~80% faster.
  • Improved Array#{==, !=} performance. ~25% faster.
  • Improved Hash#{==, !=} performance. ~50% faster.
  • Improved Range literals performance. ~20% faster.
  • [iOS] Fixed a bug with the flick' UI test helper not working withUISwitch’ on iOS 7.
  • [iOS] Added support for launching an application for background fetch in
    the iOS Simulator with the `background_fetch=1′ rake option.
  • [iOS] No longer query the simulator application for its window metrics when
    it is connected to a REPL but not the active application.
  • [iOS] Improved the automatic selection of codesign certificates.
  • [iOS] Improved error reporting when specifying the rake target' option
    with a version lower than the configured deployment target and when
    retina=false’ when targeting iOS 7.
  • [OSX] Fixed a bug where the REPL wouldn’t work in development mode if the
    app is sandboxed.
  • [OSX] Removed backtrace symbolication when an application is sandboxed and
    print the command to allow the user to symbolicate themselves instead.
  • Jim Weirich, 1956 – 2014. Without you I would not exist. Rest in Peace.

sudo motion update

iOS Marketing Tip of the Week by Mark Rickert

There’s a huge controversy over whether or not you should prompt users to rate your app after a certain number of uses or a predetermined user action.

I use Appirater and have experimented with releasing builds with and without it enabled. In my experience, I get zero reviews/ratings in my apps when I don’t specifically ask the user to do it. It’s unfortunate that users need a personal invitation to give feedback about an app, but in my experience it’s the only way to actually get reviews and ratings. Most users will just dismiss the dialog and move on, but those critical few who actually take the time to rate your app will make all the difference.

Ultimately, you need to decide where you fall on this issue and take what you think is the best course of action for your particular situation.



RMQ provides various features for dealing with images.

If you want to load an image from your /resources folder (which is where they should be), you can either load it and cache it (imageNamed) or load it and not cache it (NSBundle.mainBundle.pathForResource):

 rmq.image.resource('foo')  # /resources/foo@2x.png
 rmq.image.resource('foo', cached: false)
 # In a stylesheet
 st.background_image = image.resource('foo')

Capped images

Sometimes when you apply a background_image to a view you want the image to stretch to the size of the view without stretching the corners of the image, for example if you’re making a rounded button. The SDK has a nice feature for this, called UIImage#resizableImageWithCapInsets. It stretches the center of your image, but not the corners.

Let’s say you want to create this, like we did in Temple:


The red bar grows horizontally. But it has rounded caps. So we created this image image, which is the caps, plus one pixel to stretch. Here it is blown up and I dimmed the 4 caps:


Basically just the center line of it stretches, the other 4 quadrants do not. RMQ makes this very easy. You create a UIImageView, then in the style (or anywhere) you set the image like so:

 rmq.append(UIImageView, :your_style)
 # Then in your style 
 st.image = image.resource_resizable('your_image', top: 4, left: 4, right: 4, bottom: 4)

The top, left, etc, tell which parts of the image not to stretch. You can now resize your view and it will look great.

Snapshot of a view

Lastly you can get an image of a view, meaning a “screenshot” of it:

 my_image_view.image = rmq.image.from_view(some_view)

Help support the Dispatch and signup over at MotionInMotion

MotionInMotion releases a new
RubyMotion screencast each week. Here are some examples:

  • Episode 12 – Application URLs
  • Episode 11 – RMQ
  • Episode 10 – Teacup
  • Episode 9 – ProMotion + Formotion
  • Episode 7 – Working with the Camera

Sign up, it’s only $9AUD/month!

One more thing

As I was finishing the Dispatch tonight I noticed Dash‘s icon changed, it’s kind of cool. If you’re not using Dash, you really should be.


No, I’m not getting paid by them to push Dash, although I should be; Kapeli, call me, and by “call me” I mean send me money via Paypal, Bitcoin is fine too.

If you have any tips, blog posts, or want to sponsor this newsletter, please send emails to

Issue #17

RubyMotion Dispatch Has a Website

I’ve finally created a site for the Dispatch. It’s basic right now, it only has each issue. Later I will collect all the tips, apps of the week, etc, and make nice categories.

If you missed the last issue, you can find it here: issue #16

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts

Mar 4th, 2014 – “Dallas.rb – 12,000 lines of RubyMotion” by Amir Rajan

Mar 3rd, 2014 – “Real-time web rubymotion built with Ruby on Rails and RubyMotion” by moriyaman

Mar 3rd, 2014 – “screencast – Episode 13 – Dynamic Type” by Jack Watson-Hamblin

Mar 1st, 2014 – “gem – jenkins-rubymotion-plugin – Jenkins RubyMotion Plugin” by Shizuo Fujita (Watson)

Feb 28th, 2014 – “The great RubyMotion debate – snake_case vs cameCase” by Jack Watson-Hamblin

Feb 28th, 2014 – “Core Data in Motion – Chapter 2” by Lori Olson

Feb 28th, 2014 – “book – Beginning Core Data with RubyMotion” by Stefan Haflidason

Feb 27th, 2014 – “gem – motion-wiretap – A wrapper for KVO, gestures, UIControl events, and procs. Okay okay it’s pretty much ReactiveCocoa in RubyMotion” by Colin T.A. Gray

Feb 27th, 2014 – “gem – Horizontal scroll for items in iOS (RubyMotion) to mimic Pulse-like UI” by Multunus Software

Feb 27th, 2014 – “Reflecting on RubyMotion Experiences – Part 1” by Jordan Maguire

Feb 27th, 2014 – “gem – motion-dynamic-type – Simplifying even further iOS 7’s Dynamic Type” by Jack Watson-Hamblin

Feb 25th, 2014 – “Learn RubyMotion Episode 19 – Using lock code functionality when user leaves the app idle in the foreground” by Neeraj Singh

iOS Marketing Tip of the Week by Mark Rickert

How did you decide on the price of your paid app? A good way to figure out a general price range is to show someone (not friends or family) your app and ask “how much would you pay for this?” Once you get a general pricepoint start playing with the price in iTunes Connect to find the “sweet spot”.

The demand curve for your app changes as the price changes in an effect called price elasticity of demand. Demand will go down as your price goes up. How much demand changes depends on a number of factors including similar app availability (and price) and how necessary the app is to a user. Since the supply of digital goods is technically unlimited, the only thing we can do to measure change in demand is simply change the price.

Once you’ve played with the price of your app a bit, you’ll be able to find that sweet spot of income per download vs. demand of the app to reach the maximum downloads at the highest price. This is where you should keep the price of your app. Remember: not all apps need to be or should be $0.99.

App Development Tip by Gant Laborde

###App Icons
Many of us don’t have a designer on hand, so we end up doing a “good enough” hodgepodge of graphics, or we find a template that we feel we can work with and spend a good bit of time modifying it to our needs. After dealing with as much stock photography, and photoshop as I could handle, I took a risk on Fiverr.

If you’re unfamiliar with Fiverr, it’s services rendered for $5, and the majority of it is absolutely horrible. Odds are you are going to get worse than what you pay for. But every so often you find a gem, and it almost makes up for all those other wasted Fiverr purchases.

Fortunately, I think I found a nice one, and I’m sharing it here with you. My app is called 10-20-30 Running and simply by sending them what I came up with, they got back with me with this:

(left: mine, right: theirs)

I purchase the $5 version, to see if they had any talent, and then later spent the $10 to get the actual .PSD file from them. Total investment $15 for a classy app icon, that fits the iOS7 theme.

The Fiverr Gig

CDQ News and Tips by Ken Miller

Using CDQ with Restkit

One of the advantages of using CoreData with RubyMotion is that you can hook
into the large library of Objective-C tools that are designed to complement it.
One very popular one is RestKit, which you can use to bind your objects to REST
APIs. Whenver you access the network and perform sync-type operations, which
might involve a lot of IO activity, it’s best to perform all of that in a background
thread, and that’s just what RestKit does for you. However, using it with CDQ
involves setting things up a bit differently than the simple case, because
RestKit really wants to manage your NSManagedObjectContexts for you, and so
you have to tell CDQ where to look.

Fortunately, we can still use CDQ to manage the model and the persistent store,
but we will skip the context setup with CDQ, and let RestKit do that. So first of
all do NOT call cdq.setup as usual. Instead, just create your RKManagedObjectStore
and pass it the store from CDQ, which will get set up implicitly:

@store = RKManagedObjectStore.alloc.initWithPersistentStoreCoordinator(cdq.stores.current)

Now that you’ve told RestKit to create the contexts, you need to tell CDQ about them:


RestKit uses the private queue peristence model to good effect, so you’ll want both of these.

One last, very important note: when you sync using RestKit, you do not need to
call, and in fact, doing so may cause hard-to-debug race conditions. Only if
you mean to save locally only and don’t intend to sync right away should you call

Help support the Dispatch and signup over at MotionInMotion

MotionInMotion releases a new
RubyMotion screencast each week. Here are some examples:

  • Episode 12 – Application URLs
  • Episode 11 – RMQ
  • Episode 10 – Teacup
  • Episode 9 – ProMotion + Formotion
  • Episode 7 – Working with the Camera

Sign up, it’s only $9AUD/month!

One more thing


If you have any tips, blog posts, or want to sponsor this newsletter, please send emails to