Skip to content

mbrandonw/NSAttributedString-Encoding

Repository files navigation

#NSAttributedString+Encoding - To NSData and back

This category adds two methods to NSAttributedString that allows you to easily convert instances to NSData and back. For example,

NSAttributedString *string = [[NSAttributedString alloc] initWithString:... attributes:...];
NSData *encoded = [string convertToData];
NSAttributedString *decoded = [NSAttributedString attributedStringWithData:encoded];

Unfortunately, it is not necessarily true that [string isEqualToAttributedString:decoded] due to some unsupported features of attributed strings. Right now we do not properly encode glyph attributes, run delegates (whatever the hell those are), and the tab stops specificer of paragraph styles. However, the decoded string is similar enough to the original that you probably won't even notice when rendering.

##Installation

We love CocoaPods, so we recommend you use it.

##Author

Brandon Williams
@mbrandonw
brandon@opetopic.com
www.opetopic.com

About

Adds methods to NSAttributedString for conversion to NSData and back.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages