I'm trying to use ReactiveCocoa bindings to bind a UITextView's attributedText to a model. However, the attributedString value does not get saved as expected. Is something wrong with this binding?
- (void)viewDidLoad {
[super viewDidLoad];
NSError *error;
NSAttributedString *attributedText = [[NSAttributedString alloc] initWithData:self.note.attributedText
options:@{NSDocumentTypeDocumentAttribute: NSRTFDTextDocumentType,
NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]}
documentAttributes:nil error:&error];
self.textTextView.attributedText = attributedText;
RAC(self.note, attributedText) = [RACObserve(self.textTextView, attributedText) map:^id(NSAttributedString *attributedText) {
return [attributedText dataFromRange:NSMakeRange(0, attributedText.length)
documentAttributes:@{NSDocumentTypeDocumentAttribute: NSRTFDTextDocumentType,
NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]}
error:nil];
}];