有没有办法在文件中包含某种富文本,并将文件加载到 NSAttributedString 中?我研究了将 .rtf 文件加载到 NSAttributed 字符串中:
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];
但这给我留下了:
Error Domain=NSCocoaErrorDomain Code=258 "The operation couldn’t be completed. (Cocoa error 258.)"
有没有办法做到这一点?