BathyScapheのリンクをクリックした時に開くアプリケーションを設定するためのツール
リビジョン | 24b08f19e42dfaa7e15d145ccbe327ad7558077c (tree) |
---|---|
日時 | 2012-07-16 22:09:14 |
作者 | masakih <masakih@user...> |
コミッター | masakih |
[Mod] プロパティを使用するように変更
[Mod] インスタンス変数にアンスコ付けた
@@ -95,9 +95,9 @@ BSLinkConductor* BSLinkC; | ||
95 | 95 | NSString *urlString = [imageURL absoluteString]; |
96 | 96 | |
97 | 97 | for(BSLinkConductorItem *item in items) { |
98 | - NSRange range = [urlString rangeOfRegexp:[item regularExpression]]; | |
98 | + NSRange range = [urlString rangeOfRegexp:item.regularExpression]; | |
99 | 99 | if(range.location != NSNotFound) { |
100 | - if([item isUseLocalCopy]) { | |
100 | + if(item.isUseLocalCopy) { | |
101 | 101 | [urlItemDict setObject:item forKey:imageURL]; |
102 | 102 | [self beginDownloadURL:imageURL]; |
103 | 103 | return YES; |
@@ -113,7 +113,7 @@ BSLinkConductor* BSLinkC; | ||
113 | 113 | NSString *urlString = [anURL absoluteString]; |
114 | 114 | |
115 | 115 | for(BSLinkConductorItem *item in items) { |
116 | - NSRange range = [urlString rangeOfRegexp:[item regularExpression]]; | |
116 | + NSRange range = [urlString rangeOfRegexp:item.regularExpression]; | |
117 | 117 | if(range.location != NSNotFound) { |
118 | 118 | return YES; |
119 | 119 | } |
@@ -189,12 +189,12 @@ BSLinkConductor* BSLinkC; | ||
189 | 189 | |
190 | 190 | - (BOOL)isPreviewerItem:(BSLinkConductorItem *)item |
191 | 191 | { |
192 | - return [[previewSelector previewerDisplayNames] containsObject:[item targetApplicationName]]; | |
192 | + return [[previewSelector previewerDisplayNames] containsObject:item.targetApplicationName]; | |
193 | 193 | } |
194 | 194 | - (BOOL)openLink:(NSURL *)anURL withItem:(BSLinkConductorItem *)item; |
195 | 195 | { |
196 | 196 | if([self isPreviewerItem:item]) { |
197 | - return [previewSelector openURL:anURL inPreviewerByName:[item targetApplicationName]]; | |
197 | + return [previewSelector openURL:anURL inPreviewerByName:item.targetApplicationName]; | |
198 | 198 | } |
199 | 199 | |
200 | 200 | NSWorkspaceLaunchOptions options = 0; |
@@ -203,13 +203,13 @@ BSLinkConductor* BSLinkC; | ||
203 | 203 | return NO; |
204 | 204 | } |
205 | 205 | |
206 | - if([item isOpenInBackground]) { | |
206 | + if(item.isOpenInBackground) { | |
207 | 207 | options |= NSWorkspaceLaunchWithoutActivation; |
208 | 208 | } |
209 | 209 | |
210 | 210 | NSWorkspace *ws = [NSWorkspace sharedWorkspace]; |
211 | 211 | BOOL result = [ws openURLs:[NSArray arrayWithObject:anURL] |
212 | - withAppBundleIdentifier:[item targetIdentifier] | |
212 | + withAppBundleIdentifier:item.targetIdentifier | |
213 | 213 | options:options |
214 | 214 | additionalEventParamDescriptor:nil |
215 | 215 | launchIdentifiers:NULL]; |
@@ -11,14 +11,14 @@ | ||
11 | 11 | |
12 | 12 | @interface BSLinkConductorItem : NSObject <NSCoding, NSCopying> |
13 | 13 | { |
14 | - NSString *name; | |
15 | - NSString *regularExpression; | |
16 | - NSString *targetApplicationName; | |
14 | + NSString *_name; | |
15 | + NSString *_regularExpression; | |
16 | + NSString *_targetApplicationName; | |
17 | 17 | |
18 | - BOOL openInBackground; | |
19 | - BOOL useLocalCopy; | |
18 | + BOOL _openInBackground; | |
19 | + BOOL _useLocalCopy; | |
20 | 20 | |
21 | - NSString *targetIdentifier; | |
21 | + NSString *_targetIdentifier; | |
22 | 22 | } |
23 | 23 | |
24 | 24 | @property (nonatomic, copy) NSString *name; |
@@ -22,82 +22,82 @@ static NSString *const BSLCItemUserCopyKey = @"BSLCItemUserCopyKey"; | ||
22 | 22 | |
23 | 23 | @implementation BSLinkConductorItem |
24 | 24 | |
25 | -@synthesize name, regularExpression, targetApplicationName; | |
26 | -@synthesize targetIdentifier; | |
27 | -@synthesize openInBackground, useLocalCopy; | |
25 | +@synthesize name = _name, regularExpression = _regularExpression, targetApplicationName = _targetApplicationName; | |
26 | +@synthesize targetIdentifier = _targetIdentifier; | |
27 | +@synthesize openInBackground = _openInBackground, useLocalCopy = _useLocalCopy; | |
28 | 28 | |
29 | 29 | - (id)init |
30 | 30 | { |
31 | 31 | if(self = [super init]) { |
32 | - [self setName:[self defaultName]]; | |
33 | - [self setRegularExpression:@"http://.*"]; | |
34 | - [self setTargetApplicationName:@""]; | |
35 | - [self setOpenInBackground:NO]; | |
36 | - [self setUseLocalCopy:NO]; | |
32 | + self.name = [self defaultName]; | |
33 | + self.regularExpression = @"http://.*"; | |
34 | + self.targetApplicationName = @""; | |
35 | +// self.openInBackground = NO; | |
36 | +// self.useLocalCopy = NO; | |
37 | 37 | } |
38 | 38 | |
39 | 39 | return self; |
40 | 40 | } |
41 | 41 | - (void)dealloc |
42 | 42 | { |
43 | - self.name = nil; | |
44 | - self.regularExpression = nil; | |
45 | - self.targetApplicationName = nil; | |
46 | - [targetIdentifier release]; | |
43 | + [_name release]; | |
44 | + [_regularExpression release]; | |
45 | + [_targetApplicationName release]; | |
46 | + [_targetIdentifier release]; | |
47 | 47 | |
48 | 48 | [super dealloc]; |
49 | 49 | } |
50 | 50 | |
51 | 51 | - (void)setTargetApplicationName:(NSString *)inAppName |
52 | 52 | { |
53 | - if([targetApplicationName isEqualToString:inAppName]) return; | |
53 | + if([_targetApplicationName isEqualToString:inAppName]) return; | |
54 | 54 | |
55 | - [targetApplicationName autorelease]; | |
56 | - targetApplicationName = [inAppName copy]; | |
55 | + [_targetApplicationName release]; | |
56 | + _targetApplicationName = [inAppName copy]; | |
57 | 57 | |
58 | 58 | NSWorkspace *ws = [NSWorkspace sharedWorkspace]; |
59 | - NSString *fullPath = [ws fullPathForApplication:targetApplicationName]; | |
59 | + NSString *fullPath = [ws fullPathForApplication:_targetApplicationName]; | |
60 | 60 | if(!fullPath) { |
61 | - targetIdentifier = nil; | |
61 | + _targetIdentifier = nil; | |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | NSBundle *bundle = [NSBundle bundleWithPath:fullPath]; |
65 | 65 | if(!bundle) { |
66 | - targetIdentifier = nil; | |
66 | + _targetIdentifier = nil; | |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - targetIdentifier = [[bundle bundleIdentifier] copy]; | |
70 | + _targetIdentifier = [[bundle bundleIdentifier] copy]; | |
71 | 71 | } |
72 | 72 | |
73 | 73 | - (id)copyWithZone:(NSZone *)zone |
74 | 74 | { |
75 | 75 | BSLinkConductorItem *result = [[[self class] allocWithZone:zone] init]; |
76 | - [result setName:name]; | |
77 | - [result setRegularExpression:regularExpression]; | |
78 | - [result setTargetApplicationName:targetApplicationName]; | |
79 | - [result setOpenInBackground:openInBackground]; | |
80 | - [result setUseLocalCopy:useLocalCopy]; | |
76 | + result.name = self.name; | |
77 | + result.regularExpression = self.regularExpression; | |
78 | + result.targetApplicationName = self.targetApplicationName; | |
79 | + result.openInBackground = self.isOpenInBackground; | |
80 | + result.useLocalCopy = self.isUseLocalCopy; | |
81 | 81 | |
82 | 82 | return result; |
83 | 83 | } |
84 | 84 | |
85 | 85 | - (void)encodeWithCoder:(NSCoder *)aCoder |
86 | 86 | { |
87 | - [aCoder encodeObject:name forKey:BSLCItemNameKey]; | |
88 | - [aCoder encodeObject:regularExpression forKey:BSLCItemREKey]; | |
89 | - [aCoder encodeObject:targetApplicationName forKey:BSLCItemAppNameKey]; | |
90 | - [aCoder encodeBool:openInBackground forKey:BSLCItemOpenBGKey]; | |
91 | - [aCoder encodeBool:useLocalCopy forKey:BSLCItemUserCopyKey]; | |
87 | + [aCoder encodeObject:self.name forKey:BSLCItemNameKey]; | |
88 | + [aCoder encodeObject:self.regularExpression forKey:BSLCItemREKey]; | |
89 | + [aCoder encodeObject:self.targetApplicationName forKey:BSLCItemAppNameKey]; | |
90 | + [aCoder encodeBool:self.isOpenInBackground forKey:BSLCItemOpenBGKey]; | |
91 | + [aCoder encodeBool:self.isUseLocalCopy forKey:BSLCItemUserCopyKey]; | |
92 | 92 | } |
93 | 93 | - (id)initWithCoder:(NSCoder *)aDecoder |
94 | 94 | { |
95 | 95 | self = [self init]; |
96 | - [self setName:[aDecoder decodeObjectForKey:BSLCItemNameKey]]; | |
97 | - [self setRegularExpression:[aDecoder decodeObjectForKey:BSLCItemREKey]]; | |
98 | - [self setTargetApplicationName:[aDecoder decodeObjectForKey:BSLCItemAppNameKey]]; | |
99 | - [self setOpenInBackground:[aDecoder decodeBoolForKey:BSLCItemOpenBGKey]]; | |
100 | - [self setUseLocalCopy:[aDecoder decodeBoolForKey:BSLCItemUserCopyKey]]; | |
96 | + self.name = [aDecoder decodeObjectForKey:BSLCItemNameKey]; | |
97 | + self.regularExpression = [aDecoder decodeObjectForKey:BSLCItemREKey]; | |
98 | + self.targetApplicationName = [aDecoder decodeObjectForKey:BSLCItemAppNameKey]; | |
99 | + self.openInBackground = [aDecoder decodeBoolForKey:BSLCItemOpenBGKey]; | |
100 | + self.useLocalCopy = [aDecoder decodeBoolForKey:BSLCItemUserCopyKey]; | |
101 | 101 | |
102 | 102 | return self; |
103 | 103 | } |
@@ -105,7 +105,7 @@ static NSString *const BSLCItemUserCopyKey = @"BSLCItemUserCopyKey"; | ||
105 | 105 | - (id)description |
106 | 106 | { |
107 | 107 | return [NSString stringWithFormat:@"%@<%p> {name = %@, regularExpression = %@, targetApplicationName = %@", |
108 | - NSStringFromClass([self class]), self, name, regularExpression, targetApplicationName]; | |
108 | + NSStringFromClass([self class]), self, self.name, self.regularExpression, self.targetApplicationName]; | |
109 | 109 | } |
110 | 110 | |
111 | 111 | @end |