ReactiveCocoa/ReactiveCocoa — pull request #1018 by mdiep (2013-12-19 21:03:32+00:00)
Title: Add an extension to `NSUserDefaults` to create a channel for a key

This adds an extension to make it easy to create a channel for a user defaults key. This makes it easy to bind properties to a defaults key with `RACChannelTo` and support KVO. Instead of passing a key name around, use the property and get autocompletion.

```
@interface MyController ()

@property (assign, atomic) BOOL someProperty;

@end

@implementation MyController

- (id)init {
self = [super init];
if (self == nil) return nil;

RACChannelTo(self, someProperty, @NO) = [NSUserDefaults.standardUserDefaults rac_channelTerminalForKey:@"MyControllerKeyName"];

return self;
}

- (void)doSomething {
if (!self.someProperty) return;

NSLog(@"someProperty was true!")
}

@end
```

This trivial example doesn't really communicate the power. But exposing this as a KVO-compliant property makes it easy to use the default in FRP and easy to inspect in more traditional code.