On Sep 26, 2014, at 13:59:000, SevenBits wrote:

Hello there,

I’m curious about one thing.

For one of my applications, I need to show the license for the application. In my About window, I have a button which you can click to open the acknowledgments and open source licenses, etc in TextEdit. The problem with TextEdit, though, is that the user can modify the document if they have permission to write to the directory where my application is stored. This isn’t good. Right now, my code is as follows:

- (IBAction)showAcknowledgementsButtonPressed:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Acknowledgements" ofType:@"rtf"]; [[NSWorkspace sharedWorkspace] openFile:path withApplication:@"Safari"];
}

- (IBAction)showLicenseAgreementButtonPressed:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; [[NSWorkspace sharedWorkspace] openFile:path withApplication:@"Safari"];
}

So, what can I realistically do? Because of the formatting, I need to use RTF format to display the documents.

Any suggestions from the Cocoa crusaders? ;)

— SevenBits


Hello,


My preferred method is to create a simple window with an NSTextView (via nib or via code), then at runtime (e.g. that window's controller's awakeFromNib)
load it with the file....

NSString* path = [[NSBundle mainBundle] pathForResource:@"License" ofType:@"rtf"];
        [licenseTextView readRTFDFromFile:path];

Another way would be to copy the license to the temporary directory, then open the file from there the same way as you have been doing.
Something like:
NSString* path = [[NSBundle mainBundle] pathForResource:@"License" ofType:@"rtf"]; NSString* tempPath = [[[NSBundle mainBundle] bundleIdentifier] stringByAppendingString:@"_License.rtf"]; tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent: tempPath]; [[NSFileManager defaultManager] copyItemAtPath:path toPath: tempPath error:&error]; [[NSWorkspace sharedWorkspace] openFile: tempPath withApplication:@"TextEdit"];





Manoah F. Adams
develo...@federaladamsfamily.com
federaladamsfamily.com/developer

===========




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to