From 9470e6bc036295cd3aaa9546c3993b244372f9c0 Mon Sep 17 00:00:00 2001 From: Alistair McMillan Date: Wed, 11 Apr 2012 02:01:49 +0100 Subject: [PATCH] Change plain text URL to clickable URL --- FlashbackChecker/AppDelegate.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/FlashbackChecker/AppDelegate.m b/FlashbackChecker/AppDelegate.m index 5e1294e..b4d8019 100644 --- a/FlashbackChecker/AppDelegate.m +++ b/FlashbackChecker/AppDelegate.m @@ -72,8 +72,21 @@ - (IBAction)checkForInfection:(id)aSender [self log:@"No Signs of infection were found."]; } - NSString* theVisit = @"\n\nVisit the F-Secure site for more information:\nhttp://www.f-secure.com/v-descs/trojan-downloader_osx_flashback_i.shtml"; + NSString* theVisit = @"\n\nVisit the F-Secure site for more information:"; [self log:theVisit]; + + // There must be a simpler way to do this, right? + NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:@"http://www.f-secure.com/v-descs/trojan-downloader_osx_flashback_i.shtml"]; + NSRange range = NSMakeRange(0, [attrString length]); + [attrString beginEditing]; + [attrString addAttribute:NSLinkAttributeName value:[[NSURL URLWithString:@"http://www.f-secure.com/v-descs/trojan-downloader_osx_flashback_i.shtml"] absoluteString] range:range]; + [attrString addAttribute:NSForegroundColorAttributeName value:[NSColor blueColor] range:range]; + [attrString addAttribute: + NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSSingleUnderlineStyle] range:range]; + [attrString endEditing]; + + [[textView textStorage] appendAttributedString:attrString]; + [attrString autorelease]; }