Skip to content

Instantly share code, notes, and snippets.

@ashfurrow
Created May 21, 2013 17:51
Show Gist options
  • Save ashfurrow/5621791 to your computer and use it in GitHub Desktop.
Save ashfurrow/5621791 to your computer and use it in GitHub Desktop.
ReactiveCocoa Chaining Example
RACSignal *intervalSignal = [RACSignal interval:1];
RACSignal *startedIntervalSignal = [intervalSignal startWith:[NSDate date]];
RACSignal *mappedIntervalSignal = [startedIntervalSignal map:^id(NSDate *value) {
NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:value];
return [NSString stringWithFormat:@"%d:%02d", dateComponents.minute, dateComponents.second];
}];
RAC(self.textField.text) = mappedIntervalSignal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment