There are a few libraries out there that provide an improved syntax for Key-Value observing, but I’ve come across a library that takes things a step further.
This new library known as ReactiveCocoa is similar to .NET’s reactive extensions (but for Objective-C) and is based on the reactive programming paradigm which is probably best explained with this quote from Wikipedia:
in an imperative programming setting, a := b + c would mean that a is being assigned the result of b + c in the instant the expression is evaluated. Later, the values of b and c can be changed with no effect on the value of a.
In reactive programming, the value of a would be automatically updated based on the new values.
And the Github page for ReactiveCocoa states these benefits:
- The ability to compose operations on future data.
- An approach to minimizing state and mutability.
- A declarative way to define behaviors and the relationships between properties.
- A unified, high-level interface for asynchronous operations.
- A lovely API on top of KVO.
ReactiveCocoa is by Josh Abernathy of Github.
You can find the ReactiveCocoa repository on Github here along with several syntax examples.
Nick from Velti Inc. has some great examples demonstrating why this library is so cool on his blog.
©2012 iPhone, iOS 5, iPad SDK Development Tutorial and Programming Tips. All Rights Reserved.
.





