Load NSAttributedString from File

Posted by Wayfarer on Stack Overflow See other posts from Stack Overflow or by Wayfarer
Published on 2013-09-30T23:04:52Z Indexed on 2013/11/08 3:54 UTC
Read the original article Hit count: 282

Filed under:
|
|
|

Is there a way to have some sort of rich text in a file, and load the file into an NSAttributedString? I looked into loading a .rtf file into an NSAttributed String:

NSString *filePathFooter = [[NSBundle mainBundle] pathForResource:kFooterFileName ofType:@"rtf"];

NSError *error = nil;
NSAttributedString *string = [[NSAttributedString alloc] initWithFileURL:[NSURL URLWithString:filePathFooter]
                                                                 options:nil
                                                      documentAttributes:NULL
                                                                   error:&error];

But this leaves me with:

Error Domain=NSCocoaErrorDomain Code=258 "The operation couldn’t be completed. (Cocoa error 258.)"

Is there a way to do this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios