Message:

Subscribe rss
Blog categories
All | Backendless features
Block-based callbacks in Backendless SDK for iOS
July 26, 2013 by markpiller
Spread the love

Blocks are a powerful C-language feature that is part of Cocoa application development. They are similar to “closures” and “lambdas” you may find in scripting and programming languages such as Ruby, Python, and Lisp. For a more in-depth review of blocks, see “a short practical guide to blocks”. A Backendless user has recently asked us about the ability to handle asynchronous APIs via block-based callbacks. Since this is a very reasonable request, we added support for blocks and it is available in the latest version of the Backendless SDK for iOS. Below is an example of using the new feature with the user registration and login APIs (btw, the feature is available for ALL Backendless APIs):

By the way, here is an example of code that does the same thing, but synchronously:

The example below demonstrates the usage of block callbacks with the Data Service API in order to:

  • Persist a complex type (an instance of class Weather)
  • Find an object by ID
  • Finding first and last instances
  • Deleting an object by its objectId

If you prefer to use the synchronous (blocking) API, the follow code does the same thing as the example above (but synchronously):

Enjoy!

Share this post
Tweet about this on TwitterShare on FacebookGoogle+