Re: Showing Application Credits
Re: Showing Application Credits
- Subject: Re: Showing Application Credits
- From: "Manoah F. Adams" <email@hidden>
- Date: Sat, 27 Sep 2014 04:41:09 -0700
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
email@hidden
federaladamsfamily.com/developer
===========
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden