Introduction to ReactiveCocoaPosted on 10 Apr 2014
ReactiveCocoa is the go-to framework for Functional Reactive Programming (FRP) in objective-C. It is gaining momentum in the iOS and OSX world, having been championed (and written by) the great folks at Github.
In addition to being the ShinobiControls CTO, Colin Eberhardt is also a member of the tutorial team over at raywenderlich.com. His latest tutorial was titled “ReactiveCocoa Tutorial: The Definitive Introduction” and is available in two parts:
- ReactiveCocoa Tutorial: The Definitive Introduction: Part 1/2
- ReactiveCocoa Tutorial: The Definitive Introduction: Part 2/2
On Tuesday of this week, Ray asked Colin to present a video tech-talk for the site – a whistlestop tour of ReactiveCocoa, and how to get started with it. The video is embedded below, but you can head on over to the tech-talk page for more information and useful links.
I have never used ReactiveCocoa, but whilst watching the video I was struck by a couple of things:
- The elegance of FRP for managing user interaction. Mobile apps are necessarily very UI-heavy. This means that they rely on events – such as a user tapping a button, or typing in a text field. FRP leverages this to wire up small methods which will be called in response to changes, both in the UI and elsewhere. You can combine these streams of events into a pipeline of operations, which has the same effect as the standard procedural code, but in a much more expressive (and shorter) fashion.
- Objective-C syntax was not built for method-chaining. When building up the a pipeline to process the event stream, ReactiveCocoa uses the concept of method chaining. This means that each phase of the pipeline is a method which adds a block of code to the previous. In objective-C, due to the use of square-brackets  to denote message sending, this results in a large number of square brackets [[[[[[[[[[ at the start of a pipeline, making the code a little complicated to decipher. Combined with the somewhat awkward block syntax, this results in code which isn’t as readable as it could be in more classical .method() syntax languages (such as java, c#).
I’m really keen to give ReactiveCocoa a try now – it looks fun to learn, and offers an insight into a different programming paradigm.
I’m thinking about playing around with ReactiveCocoa in the context of wiring it up to some Shinobi products. If you’re interested in this, or anything else ReactiveCocoa-focused, then leave a comment at the bottom of the page – I’m interested to see whether I’m alone
Back to News