Do you want to be a RubyMotion hero? Write a wrapper around RestKit

I’m working with a client and we’re using both CDQ and RestKit. CDQ is for the local Core Data store and it works really well. On a side-note Ken Miller said he would write a weekly CDQ tip for the Dispatch. We use RestKit to connect to a Rails server and sync the data. It’s very full featured and great, but there is a lot of boilerplate and complexity. It’s begging for a nice ruby wrapper.

Happy coding, Todd Werth (@twerth)

Motion Meetup Announcement

The next Motion Meetup is tomorrow, here is the Google+ page. The guest this week will be me, woot :-). Come join us, it will be fun.

Articles, News, New Gems, and Blog Posts

Feb 4th, 2014 – “Rails developers can build iOS and OS X Apps too! New Book – RubyMotion for Rails Developers” by Jack Watson-Hamblin

Feb 3th, 2014 – “I use the WebSocket from RubyMotion” by bellx2

Feb 2th, 2014 – “Statically Compiling Ruby with LLVM” by Laurent Sansonetti

Feb 2th, 2014 – “Laying out a custom UITableViewCell using AutoLayout support of Teacup” by t_nakamura

Jan 31th, 2014 – “Video: RubyMotion Support in RubyMine” by JetBrains

Jan 29th, 2014 – “OS X Apps with Ruby: Part 2” by Jack Watson-Hamblin

Jan 28th, 2014 – “Leaving Debug Code in Production Apps” by Mark Rickert

Why MotionPrime” by Iskander Haziev

RubyMotion News

IMPORTANT – remote templates are currently broken, they will be fixed in the next update of RubyMotion but can be patched now with this. 

RubyMotion 2.22 – February 3rd, 2014

  • Fixed a bug with `vendor_project’ and prebuilt libraries, where the BridgeSupport file could not be created, as the build directory wouldn’t exist yet.
  • Fixed a bug with `vendor_project’ and Xcode projects, where the BridgeSupport files were being searched in the wrong location.

RubyMotion 2.21 – February 3rd, 2014

  • Added reference zeroing to `WeakRef’ starting from iOS 5 and OS X 10.7. It will now raise an exception in case a message is sent after the reference has been deallocated. Use the `WeakRef#weakref_alive?’ method to check if it has been deallocated or not.
  • Improved performance where Array elements would be converted from Ruby to Objective-C instance. ~10% faster.
  • Fixed a bug where incorrect SDK version values were being used in the Info.plist file resulting in iOS App Store submissions being rejected.
  • Fixed a bug where `motion update –cache-version=X’ is broken.
  • Fixed a bug where vendored Xcode OS X projects were build with the IPHONEOS_DEPLOYMENT_TARGET option instead of MACOSX_DEPLOYMENT_TARGET.
  • Fixed a memory leak where the objects with a cyclic reference would not be released when used inside an asynchronous Dispatch::Queue.
  • Fixed a bug where BridgeSupport files for external projects included via `vendor_project’ were being shared across platform and not removed with `rake clean’.

RubyMotion 2.20 – January 28th, 2014

  • Improved command-line interface, e.g. `$ motion create –help’ will now no longer create an application called ‘–help’. This deprecates the interface for any command plugins and this will fully be removed with RubyMotion v3.
  • Added support for loading plugins through RubyGems. Libraries that used to use `~/Library/RubyMotion’ to load commands and/or templates should no longer do so, but instead add a `lib/motion_plugin.rb’ file (see Joybox for an example). The `~/Library/RubyMotion’ is from now on only meant for local usage, i.e. outside of the scope of a gem.
  • Added the Proc#owner method, which returns a reference to the object the block was created from (the `self’ reference).
  • Improved Rational performance. ~4 times faster.
  • Improved Proc#new performance. 15% faster.
  • Improved performance of Range objects created with the literal syntax.  ~80% faster.
  • Improved Object#inspect performance. ~25% faster.
  • Improved Object#!~ performance. ~3 times faster.
  • Improved Object#{send, respond_to?} performance. ~30% times faster.
  • Improved performance in dispatcher. ~25% faster.
  • Improved performance of arithmetic methods with Float objects in 32-bit.  ~80% faster.
  • Fixed a bug where methods accepting variadic arguments would not be working as expected when a method of the same signature was used before.
  • Fixed a bug in the build system with Ruby 2.1 where an application whose name contains UTF-8 characters could not be built.
  • Fixed a race condition bug in the runtime where a crash would occur if the same Objective-C constant was being resolved at the same time from different threads.
  • Fixed the runtime to be able to deal with all tagged pointers from the Objective-C world. For instance, using NSTaggedManagedObjectID would lead to a runtime crash.
  • Fixed a bug where the user defined bang (!) method would be not called.
  • Fixed a memory leak when creating compile time constants.
  • Fixed a memory leak in
  • Fixed a memory leak in Array#shift.
  • Fixed a bug where Method#to_proc would not return a lambda block.
  • Fixed a bug where CFType structures in AudioToolbox could not be used.
  • Fixed a bug which Kernel.raise could not raise an NSException object.
  • Fixed a bug where #alias and #respond_to? methods would cause a race condition.
  • Fixed a bug in the compiler that would ignore BridgeSupport enum values if they only have a 64-bit value.
  • Fixed a bug where NSMutableArray#delete_at would immediately release an object.
  • Made `vendor_project’ accept glob patterns for the `source_files’ option.
  • Made BridgeSupport metadata generation for `vendor’ projects by default use the `:cflags` option.
  • [iOS] Made the UI test helper search for views from the `keyWindow’ instead of the `current’ window that was created specifically for the test. This makes it easier to interact with modal views such as `UIAlertView’.
  • [iOS] Fixed a bug in the build system where a link error would be caused when building for arm64 with Xcode 5.1. Thanks to Andrew Larssen for the patch (pull request #146).
  • [OSX] Fixed a bug where an NSDate object convered to a Time object would cause a calculation error.
  • [OSX] Fixed the `rake crashlog’ task.
  • [OSX] Added `external_frameworks’ config variable, which is used for frameworks that are outside of `/System/Library/Frameworks`, but are not meant to be embedded inside the application.  E.g. `/Library/Frameworks/iTunesLibrary.framework’.
  • [OSX] Fixed a bug where method types of NSOpenPanel and NSSavePanel were not being cached for their private counterparts that are substituted at runtime in case the application is running in a sandbox.

sudo motion update

RubyMotion App of the Week

TicketZen – “Parking tickets suck. Paying them doesn’t have to.”

RubyMotion Tip of the Week

Cyclic Counting and Coding by Gant Laborde

If you don’t use the modulus operator for cyclic counting, you’re about to learn an amazing coding tip that will stick with you for life.  It seems at least once a year, I get to utilize this operator for cycles and re-impress myself with it’s elegance.

The utility is endless (e.g. traversing strings, state machines, time, animations).

You want to cycle over 3 values or states (i.e. 0,1,2,0,1,2,0,1,2)

Conditional logic would be an abomination; handle this eloquently with math and modulus. The code looks like so:

# Generate state of 0,1,2,0,1,2
def tick
@clock = (@clock + 1) % 3

Each time the tick method returns the next state.

This also facilitates initializing the @clock at a value of -1, should you want an off state.

For simplicity I’ve used an instance variable and hardcoded cycle size integer.

RMQ News

A very minor update was released: version 0.5.1


Do you want to see how to do a collection view in RubyMotion and RMQ?

Create a UICollectionViewController with this:
rmq create collection_view_controller foo

This generates all the code for you.

Some cool animations done by Josh Smith using rmq

Video 1 and video 2

One more thing

I cracked myself up with that one :-)Last week I asked about HockeyApp. A few readers responded that they used it and liked it a lot.