Monthly Archives: August 2014

Issue #41

Grid Playground

Chuck Newport and the prolific Gant Laborde have written a super cool tool called the RMQ Grid Playground.

image


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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


August 22th, 2014 | blog post | by Sunil Kumar
SSL Pinning With Rubymotion

August 22th, 2014 | blog post | by Will Raxworthy
Chromecasting with RubyMotion

August 20th, 2014 | blog post | by Stalin
RubyMotion Query (RMQ) Validations – Allow blank

Note, this is fixed in RMQ edge

August 19th, 2014 | blog post | by Kamil Lelonek
Concurrency patterns in RubyMotion

August 18th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 38 – RMQ Validations

August 17th, 2014 | blog post | by Jamon Holmgren
Creating a Custom UITableViewCell with ProMotion

August 12th, 2014 | example app | by Gant Laborde
JGProgressHUD Pod in RubyMotion

September 17th, 2014 | conference in Japan | by Shizuo Fujita (Watson)
RubyMotion Kaigi 2014

RubyMotion App of the Week


image

BAGtheapp by Nacho Rapallo

From the Archives


Because it’s easier to copy and paste than to write

NS classes

Dates inherit NSDate, strings inherit NSMutableString (which inherits NSString), and arrays inherit NSMutableArray (which inherits NSArray).

This is useful because you get all the normal Ruby string stuff, but you also get the NSMutableString and NSString stuff. There are some cool things in there, check out the docs (and use Dash for your docs)

Here is a cool example, NSArray has the pathsMatchingExtensions method:

(main)> [ '/foo/bar/hello.txt', 'report.pdf', '/user/me/resume.doc' ].pathsMatchingExtensions([ 'txt', 'doc' ])
 => ["/foo/bar/hello.txt", "/user/me/resume.doc"]
(main)>

Sponsor


My company InfiniteRed sponsors this newsletter by allowing me the time to work on it every week and hosting everything.

Contact us if you ever need help working on a project, mentoring, or other development services . We specialize in RubyMotion and have an awesome team.

image

Wat!


The dilemma of mobile apps development


If you have any tips, blog posts, or comments, please send emails to todd@infinitered.com

Issue #40

Just-in-time libraries

When I was a younger fellow, I would dream up perfectly formed libraries. I would marvel at how beautiful they were and how clever I was. Sometimes I would actually use the library in a project, sometimes not.

As I got older I started to build “just-in-time libraries”, which are libraries that you build only when you need them during the actual creation of a real project.

These kind of libraries are not complete, aren’t as beautiful to behold, and often have pragmatic things that aren’t 100% consistent. However they are guaranteed to be used and are naturally optimized to solve the problems that actually exist.

The reason I’m telling you this little story is because RMQ 0.7 was just released with a new feature: validations. It, like the rest of RMQ, was born during frustration while working on an actual project.

Gant Laborde create the validations feature and it’s a cool one. Thank you Gant.

See RMQ news below for more info on validations.


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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


August 14th, 2014 | new meetup
London RubyMotion meetup

August 11th, 2014 | blog post | by Rob Horrigan
RubyMotion 3.0: Android support

August 11th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 37 – Test Driven Development and Creating a Gem Part 2

August 9th, 2014 | blog post | by Kamil Lelonek
RubyMotion app with Facebook SDK

August 8th, 2014 | blog post | by Lori Olson
Static Tables in Code

August 7th, 2014 | blog post | by Gant Laborde
Dealing with bad data and the Hash structure’s defenses:

RubyMotion App of the Week


image

Hacker Bar by Mark Rickert

GitHub repo

Gems used in the app:

  • bubble-wrap
  • afmotion
  • motion-cocoapods
  • ib
  • menu-motion
  • motion_print

Pods used in the app:

  • Mixpanel-OSX-Community
  • Ono

RMQ News


Validations

Version 0.7 was just released. The major new feature is validations. They were created by Gant Laborde

Read the documentation here

# Examples of the Utility
rmq.validation.valid?('https://www.infinitered.com', :url) #true
rmq.validation.valid?(98.6, :number) #true


# Examples of Selection Rules
rmq.append(UITextField, :user).validates(:email)
rmq.append(UITextField, :password).validates(:strong_password)
rmq.append(UITextField, :pin).validates(:digits).validates(:length, exact_length: 5)

rmq(UITextField).valid? # checks if selected is valid
rmq(:password).clear_validations! #removes validations on selected

Hidden Gem by Gant Laborde


Avoiding begin/rescue for Hashes

In RubyMotion, if you were to run the following application, you can get back with me on how it went in about week or so.

n = 5000
my_hash = {a: 1, b: 2}

n.times do
  begin
    z = my_hash.fetch(:z)
  rescue
    z = 26
  end
end

Your REPL will be filled with n KeyErrors that run slowwwwwwwwww. The way RubyMotion handles exceptions is a nightmare in this particular situation. Today’s hidden gem is that Hash#fetch accepts a block. Instead you can write.

n = 5000
my_hash = {a: 1, b: 2}

n.times do
  z = my_hash.fetch(:z) do
    # do anything here.  Runs if fetch fails
    26
  end
end

This runs all 5000 in under a second. It’s a silly example, but it proves a point. For more information on Hashes, see my latest blog post: Dealing with bad data and the Hash structure’s defenses

Sponsor


My company InfiniteRed sponsors this newsletter by allowing me the time to work on it every week and hosting everything.

Contact us if you ever need help working on a project, mentoring, or other development services . We specialize in RubyMotion and have an awesome team.

image

Wat!


In Ruby:

0.1 + 0.2 == 0.3
#=> false

However, RubyMotion is correct:

0.1 + 0.2 == 0.3
=> true


If you have any tips, blog posts, or comments, please send emails to todd@infinitered.com

Issue #39

Scene Kit is coming to the Dispatch

At InfiniteRed, Will Raxworthy and I have been working on a project using Scene Kit. Scene Kit is like Sprite Kit but it’s for 3D graphics (Sprite Kit is for 2D).

There is very little documentation out there on Scene Kit, so we’ve had to figure it all out. Our pain is your gain, as I will be creating some basic gems in RubyMotion and creating some example apps.

It’s really fun stuff, stay tuned.


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

Happy coding, Todd Werth (@twerth)

Articles, News, New Gems, and Blog Posts


August 5th, 2014 | blog post | by Stalin
Audio Recording – RubyMotion

August 4th, 2014 | screencast | by Jack Watson-Hamblin
MotionInMotion – Episode 36 – Test Driven Development and Creating a Gem

August 3rd, 2014 | blog post | by Jamon Holmgren
ProMotion 2.0 Launched

August 2nd, 2014 | blog post | by Jack Watson-Hamblin
Gaining Control of RubyMotion with UIViewControllers

August 2nd, 2014 | guide | by Jamon Holmgren
Migration Guide: ProMotion 1.2 to 2.0

August 1st, 2014 | blog post | by Jack Watson-Hamblin
Starting a RubyMotion Application

RubyMotion App of the Week


image

Groceries by Ketan Anjaria

Gems used in the app:

  • afmotion
  • bubble-wrap
  • sugarcube
  • motion-testflight
  • motion-support

Pods used in the app:

  • AFNetworking
  • ViewDeck
  • Analytics/Segmentio
  • Analytics/Crittercism
  • Analytics/Mixpanel
  • Analytics/Flurry
  • Reachability
  • BSKeyboardControls
  • SVProgressHUD
  • MSLabel
  • TSMessages
  • UIDeviceIdentifier

ProMotion Tip by Mark Rickert


ProMotion is all shiny and new! There aren’t a lot of added features in 2.0.0 but you’ll find it builds 55% faster and is 20%+ lighter!

One new feature I was able to sneak past Jamon is the new ‘longpressable’ TableScreen module. You’ve always been able to fire an action for a particular table cell whenever it was tapped, but I needed a way to tap and hold to fire a different action based on that gesture. This 25-line module does just that.

Simply add longpressable to the top of your PM::TableScreen subclass (where you’d put searchable or indexable) and in your cell hashes add long_press_action: :some_action.

Internally, it adds a UILongPressGestureRecognizer to the table view and when the action is triggered, it figures out what cell your finger is on and runs the long_press_action associated with the cell!

Make sure to check out the migration guide since some other things have changed in the way TableScreen cells are passing data back and forth.

Bonus tip: longpressable defaults to 1 second, but you can modify that like this:

longpressable min_duration: 2.5

Sponsor


My company InfiniteRed sponsors this newsletter by allowing me the time to work on it every week and hosting everything.

Contact us if you ever need help working on a project, mentoring, or other development services . We specialize in RubyMotion and have an awesome team.

image

Wat!


To error is human, to force you to care about the error is Java


If you have any tips, blog posts, or comments, please send emails to todd@infinitered.com