From 5339d25dca4c160bf932c97eb4b18eb15adedae2 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 26 Dec 2011 02:39:30 +0000 Subject: [PATCH] run on Snow Leopard again --- macosx/NSApplicationAdditions.h | 1 + macosx/TorrentTableView.m | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/macosx/NSApplicationAdditions.h b/macosx/NSApplicationAdditions.h index ab85b3b8c..aff930263 100644 --- a/macosx/NSApplicationAdditions.h +++ b/macosx/NSApplicationAdditions.h @@ -23,6 +23,7 @@ *****************************************************************************/ #define NSPopoverLion NSClassFromString(@"NSPopover") +#define NSDataDetectorLion NSClassFromString(@"NSDataDetector") @interface NSApplication (NSApplicationAdditions) diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 991569540..02d416b70 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -551,7 +551,7 @@ NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil]; if (items) { - NSDataDetector * detector = [NSDataDetector dataDetectorWithTypes: NSTextCheckingTypeLink error: nil]; + NSDataDetector * detector = [NSDataDetectorLion dataDetectorWithTypes: NSTextCheckingTypeLink error: nil]; for (NSString * pbItem in items) { for (NSTextCheckingResult * result in [detector matchesInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])]) @@ -572,14 +572,17 @@ if ([[[NSPasteboard generalPasteboard] types] containsObject: NSURLPboardType]) return YES; - NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil]; - if (items) + if ([NSApp isOnLionOrBetter]) { - NSDataDetector * detector = [NSDataDetector dataDetectorWithTypes: NSTextCheckingTypeLink error: nil]; - for (NSString * pbItem in items) + NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil]; + if (items) { - if ([detector firstMatchInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])]) - return YES; + NSDataDetector * detector = [NSDataDetectorLion dataDetectorWithTypes: NSTextCheckingTypeLink error: nil]; + for (NSString * pbItem in items) + { + if ([detector firstMatchInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])]) + return YES; + } } }