获取iPhone已经安装程序列表

首先,必须确定iPhone是越狱的,并且你的下面代码运行的目录为/Applications/.

NSFileManager
* fileManager = [NSFileManager defaultManager];
NSMutableArray
* applist = [NSMutableArray arrayWithCapacity:10];
for (NSString *path in [fileManager directoryContentsAtPath:@"/var/mobile/Applications"]) {
for (NSString *subpath in [fileManager directoryContentsAtPath:
[NSString stringWithFormat:
@"/var/mobile/Applications/%@", path]]) {
if ([subpath hasSuffix:@".app"])
{
NSString
* infoplist = [NSString stringWithFormat:@"/var/mobile/Applications/%@/%@/Info.plist", path, subpath];
NSLog(
@"sdfsadfa0%@",infoplist);
NSDictionary
* dict = [NSDictionary dictionaryWithContentsOfFile:infoplist];
NSLog(
@"sdfsadfa1%@",dict);

[applist addObject:[dict objectForKey:
@"CFBundleDisplayName"]];
}
}

  

posted @ 2011-08-22 08:43  威尚  阅读(1419)  评论(0编辑  收藏  举报