I want to incorporate a .rtfd (...or html) file into a NSAttributedString.
I've created some class helper methods within a NSAttributedString(category) written in Objective-C.
My Question: how do I access these Objective-C methods from Swift?
The following is how I would do it in Objective-C:
NSURL *rtfURL = [[NSBundle mainBundle] URLForResource: @"Recursion" withExtension:@"rtfd"];
NSAttributedString *attrString = [NSAttributedString attributeStringFromRTFURL:rtfURL];
Here's the Objective-C class method:
+ (NSAttributedString *)attributeStringFromRTFURL:(NSURL *)rtfURL {
NSAttributedString *stringWithRTFAttributes =
[[NSAttributedString alloc] initWithFileURL:rtfURL
options:@{NSDocumentTypeDocumentAttribute:NSRTFDTextDocumentType}
documentAttributes:nil
error:nil];
return stringWithRTFAttributes;
}
Here's what I have in the .swift file:
let rtfURL = NSBundle.mainBundle().URLForResource("Recursion", withExtension: "rtfd")
let attrString = [NSAttributedString attributeStringFromRTFURL:rtfURL];
Question: What's the Swift equivalent of [NSAttributedString attributeStringFromRTFURL:rtfURL];?
Note: I'm seeking the syntax of calling a class vs instantiated method.