the future is in beta

home about

Using RestKit with RubyMotion

25 Mar 2013

The ThunderboltLabs guys have a great post about using RestKit with RubyMotion. I was trying to follow their instructions, but I noticed that some methods are deprecated in RestKit 0.20.0. Now, RestKit uses AFNetworking and some code changes.

Translating Objective-C code to Ruby is not difficult, but I had some trouble when I had to write a block.

Here is an Objective-C block,

[operation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *result) {
  NSLog(@"The public timeline Tweets: %@", [result array]);
} failure:nil];

Translated to a Ruby block in RubyMotion,

  lambda do |operation, result| 
    puts "The public timeline Tweets: " + result.array.inspect
  failure: nil)