-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathXcodeSourceTreeType.m
More file actions
48 lines (39 loc) · 1.73 KB
/
XcodeSourceTreeType.m
File metadata and controls
48 lines (39 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
////////////////////////////////////////////////////////////////////////////////
//
// JASPER BLUES
// Copyright 2012 Jasper Blues
// All Rights Reserved.
//
// NOTICE: Jasper Blues permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import "XcodeSourceTreeType.h"
static NSString* const kPBXSourceTreeSKRoot= @"SDKROOT";
static NSString* const kPBXSourceTreeGroup = @"<group>";
static NSDictionary* DictionaryWithProjectSourceTreeTypesAsStrings() {
// This is the most vital operation on adding 500+ files
// So, we caching this dictionary
static NSDictionary* _projectNodeTypesAsStrings;
if (_projectNodeTypesAsStrings) {
return _projectNodeTypesAsStrings;
}
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_projectNodeTypesAsStrings = @{
kPBXSourceTreeSKRoot : @(SourceTreeSDKRoot),
kPBXSourceTreeGroup : @(SourceTreeGroup),
};
});
return _projectNodeTypesAsStrings;
}
@implementation NSString (XcodeSourceTreeTypeExtensions)
+ (NSString*)xce_stringFromSourceTreeType:(XcodeSourceTreeType)nodeType {
NSDictionary* nodeTypesToString = DictionaryWithProjectSourceTreeTypesAsStrings();
return [[nodeTypesToString allKeysForObject:@(nodeType)] firstObject];
}
- (XcodeSourceTreeType)xce_asSourceTreeType {
NSDictionary* nodeTypesToString = DictionaryWithProjectSourceTreeTypesAsStrings();
return (XcodeSourceTreeType) [[nodeTypesToString objectForKey:self] intValue];
}
@end