Skip to content

Commit b30e0d9

Browse files
Add dictionary category to remove entries with empty string values
- Part of #87
1 parent e7e8863 commit b30e0d9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

BuildSettingExtractor/Constants+Categories.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ extern NSErrorDomain const TPSBuildSettingExtractorErrorDomain;
3737
// Returns NO if all the values in a dictionary are an empty string
3838
// Raises an exception if used on a dictionary with any non-NSString value
3939
- (BOOL)containsBuildSettings;
40+
41+
// Returns a new dictionary containing all entries in the receiver except for
42+
// entries with an empty string value.
43+
- (NSDictionary *)tps_dictionaryByRemovingEmptyStringValues;
4044
@end
4145

4246
#pragma mark -

BuildSettingExtractor/Constants+Categories.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ - (BOOL)containsBuildSettings {
7171
return foundNonEmptyString;
7272
}
7373

74+
- (NSDictionary *)tps_dictionaryByRemovingEmptyStringValues {
75+
NSMutableDictionary *temp = [[NSMutableDictionary alloc] init];
76+
[self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull value, BOOL * _Nonnull stop) {
77+
if (![value isEqualTo:@""]) {
78+
[temp setValue:value forKey:key];
79+
}
80+
}];
81+
return temp;
82+
}
83+
7484
@end
7585

7686
#pragma mark -

0 commit comments

Comments
 (0)