-
Notifications
You must be signed in to change notification settings - Fork 222
/
BHTBundle.m
50 lines (44 loc) · 1.65 KB
/
BHTBundle.m
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
49
50
//
// BHTBundle.m
// BHTwitter
//
// Created by BandarHelal on 07/08/2022.
//
#import "BHTBundle.h"
@interface BHTBundle ()
@property (nonatomic, strong) NSBundle *mainBundle;
@end
@implementation BHTBundle
+ (instancetype)sharedBundle {
static BHTBundle *sharedBundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *bundlePath = [NSURL new];
if ([fileManager fileExistsAtPath:@"/Library/Application Support/BHT/BHTwitter.bundle"]) {
bundlePath = [NSURL fileURLWithPath:@"/Library/Application Support/BHT/BHTwitter.bundle"];
} else if ([fileManager fileExistsAtPath:@"/var/jb/Library/Application Support/BHT/BHTwitter.bundle"]) {
bundlePath = [NSURL fileURLWithPath:@"/var/jb/Library/Application Support/BHT/BHTwitter.bundle"];
} else {
bundlePath = [[NSBundle mainBundle] URLForResource:@"BHTwitter" withExtension:@"bundle"];
}
sharedBundle = [[self alloc] initWithBundlePath:bundlePath];
});
return sharedBundle;
}
- (instancetype)initWithBundlePath:(NSURL *)bundlePath {
if (self = [super init]) {
self.mainBundle = [NSBundle bundleWithPath:[bundlePath path]];
}
return self;
}
- (NSString *)localizedStringForKey:(NSString *)key {
return [self.mainBundle localizedStringForKey:key value:key table:nil];
}
- (NSURL *)pathForFile:(NSString *)fileName {
return [self.mainBundle URLForResource:fileName withExtension:nil];
}
- (NSString *)BHTwitterVersion {
return [self.mainBundle objectForInfoDictionaryKey:@"BHTVersion"];
}
@end