Skip to content

Commit 86274b3

Browse files
Allow for no word separator in names of generated files
- Allow the use of an empty string to separate words in generated file names - Add EmptyStringTransformer value transformer to convert nil to empty string - Initialize new transformer in AppDelegate +initialize - In Preferences storyboary set separator text field to use value transformer - Resolves #63
1 parent 7afe676 commit 86274b3

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

BuildSettingExtractor/AppDelegate.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ @interface AppDelegate () <NSOpenSavePanelDelegate>
2626

2727
@implementation AppDelegate
2828

29+
+ (void)initialize {
30+
EmptyStringTransformer *transformer = [[EmptyStringTransformer alloc] init];
31+
[NSValueTransformer setValueTransformer:transformer forName:@"EmptyStringTransformer"];
32+
}
33+
2934
- (void)awakeFromNib {
3035
self.dragFileView.target = self;
3136
self.dragFileView.action = @selector(handleDroppedFile:);

BuildSettingExtractor/Constants+Categories.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ extern NSErrorDomain const TPSBuildSettingExtractorErrorDomain;
5959
+ (NSError *)errorForDestinationContainsBuildConfigFiles;
6060

6161
@end
62+
63+
#pragma mark -
64+
65+
@interface EmptyStringTransformer: NSValueTransformer {}
66+
@end

BuildSettingExtractor/Constants+Categories.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,26 @@ + (NSError *)errorForDestinationContainsBuildConfigFiles {
125125
}
126126

127127
@end
128+
129+
#pragma mark -
130+
131+
@implementation EmptyStringTransformer
132+
+ (Class)transformedValueClass { return [NSString class]; }
133+
+ (BOOL)allowsReverseTransformation { return YES; }
134+
135+
- (id)transformedValue:(id)value {
136+
if ([value isKindOfClass:[NSString class]] && [value isEqualToString:@""]) {
137+
return nil;
138+
} else if (value == nil) {
139+
return @"";
140+
} else {
141+
return value;
142+
}
143+
}
144+
145+
- (id)reversedTransformedValue:(id)value {
146+
if (value == nil) { return @""; }
147+
else { return value; }
148+
}
149+
@end
150+

BuildSettingExtractor/Preferences/Base.lproj/Preferences.storyboard

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,11 @@
273273
</textFieldCell>
274274
<connections>
275275
<accessibilityConnection property="title" destination="ApD-gw-uD5" id="YUV-Fq-B5t"/>
276-
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSOutputFileNameSeparator" id="fuY-Ge-NPr">
276+
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSOutputFileNameSeparator" id="aYI-51-xnh">
277277
<dictionary key="options">
278278
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
279279
<string key="NSNullPlaceholder">None</string>
280+
<string key="NSValueTransformerName">EmptyStringTransformer</string>
280281
</dictionary>
281282
</binding>
282283
</connections>

0 commit comments

Comments
 (0)