-
Notifications
You must be signed in to change notification settings - Fork 0
/
BundleLoader.m
executable file
·52 lines (45 loc) · 1.24 KB
/
BundleLoader.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
51
52
//
// BundleLoader.m
// App Pie
//
// Created by Giacomo Trezzi on 21/05/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "BundleLoader.h"
@implementation BundleLoader
/*
Trovo la mia cartella nell'applicationsupport
e la creo nel caso non esistesse
*/
- (NSString *)applicationSupportFolder
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError * error;
NSString *folder = @"~/Library/Application Support/App Pie/";
folder = [folder stringByExpandingTildeInPath];
if ([fileManager fileExistsAtPath: folder] == NO)
{
[fileManager createDirectoryAtPath:folder withIntermediateDirectories:YES attributes:nil error:&error];
NSLog(@"%@",error);
}
return folder;
}
/*
Carico il bundle collegato all'applicazione
*/
- (PieBundle *)loadBundle:(NSString*)bundleName{
id newInstance;
NSString * commonName = [self applicationSupportFolder];
NSString * name = [commonName stringByAppendingPathComponent:bundleName];
NSString * bundlePath = [name stringByAppendingString:@".pie"];
NSBundle * bundleToLoad = [NSBundle bundleWithPath:bundlePath];
newInstance = [[[bundleToLoad principalClass] alloc] init];
if (newInstance !=nil) {
return newInstance;
}
else
{
return NO;
}
}
@end