//返回一个数组
1 NSMutableArray *applist = [[NSMutableArray alloc]init];
2
3 NSString *pathOfApplications = @"/var/mobile/Applications";
4 // all applications
5 NSArray *arrayOfApplications = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathOfApplications error:nil];
6
7 for (NSString *applicationDir in arrayOfApplications) {
8
9 // path of an application
10 NSString *pathOfApplication = [pathOfApplications stringByAppendingPathComponent:applicationDir];
11 NSArray *arrayOfSubApplication = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pathOfApplication error:nil];
12 // seek for *.app
13 for (NSString *applicationSubDir in arrayOfSubApplication) {
14 if ([applicationSubDir hasSuffix:@".app"]) {// *.app
15 NSString *path = [pathOfApplication stringByAppendingPathComponent:applicationSubDir];
16 path = [path stringByAppendingPathComponent:@"Info.plist"];
17 // so you get the Info.plist in the dict
18 NSMutableDictionary *dict = [[NSDictionary dictionaryWithContentsOfFile:path]mutableCopy];
19 // code to analyzing the dict.
20 dict[@"path"] = [pathOfApplication stringByAppendingPathComponent:applicationSubDir];
21 if (ARRAY_NOT_EMPTY(dict[@"SBAppTags"])) {
22 NSArray *tags = dict[@"SBAppTags"];
23 if ([tags containsObject:@"hidden"]) {
24 [dict autorelease];
25 continue;
26 }
27 }
28 [applist addObject:dict];
29 [dict release];
30
31 }
32 }
33 }
34
35 return [applist autorelease];