-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathNSBundle+SSYMotherApp.m
46 lines (38 loc) · 1.49 KB
/
NSBundle+SSYMotherApp.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
#import "NSBundle+SSYMotherApp.h"
#import "NSBundle+MainApp.h"
#import "NSString+SSYDotSuffix.h"
@implementation NSBundle (SSYMotherApp)
- (NSString*)motherAppName {
return [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"SSYMotherAppName"] ;
}
- (NSString*)motherAppBundleIdentifier {
NSString* motherAppName = [self motherAppName] ;
NSString* answer = nil ;
if (motherAppName) {
NSString* bundleIdentifier = [self bundleIdentifier] ;
answer = [bundleIdentifier stringByDeletingDotSuffix] ;
answer = [answer stringByAppendingDotSuffix:motherAppName] ;
}
return answer ;
}
- (NSString*)applicationSupportPathForMotherApp {
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory,
NSUserDomainMask,
YES
) ;
NSString* userAppSupportPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil ;
NSString* motherAppName = [self motherAppName] ;
if (!motherAppName) {
motherAppName = [[NSBundle mainAppBundle] objectForInfoDictionaryKey:@"CFBundleName"] ;
}
NSString* answer ;
if (motherAppName) {
answer = [userAppSupportPath stringByAppendingPathComponent:motherAppName] ;
}
else {
answer = userAppSupportPath ;
}
return answer ;
}
@end