3 回答
TA贡献1852条经验 获得超7个赞
您可以使用以下代码段:
#import "InstalledAppReader.h"
static NSString* const installedAppListPath = @"/private/var/mobile/Library/Caches/com.apple.mobile.installation.plist";
@interface InstalledAppReader()
-(NSArray *)installedApp;
-(NSMutableDictionary *)appDescriptionFromDictionary:(NSDictionary *)dictionary;
@end
@implementation InstalledAppReader
#pragma mark - Init
-(NSMutableArray *)desktopAppsFromDictionary:(NSDictionary *)dictionary
{
NSMutableArray *desktopApps = [NSMutableArray array];
for (NSString *appKey in dictionary)
{
[desktopApps addObject:appKey];
}
return desktopApps;
}
-(NSArray *)installedApp
{
BOOL isDir = NO;
if([[NSFileManager defaultManager] fileExistsAtPath: installedAppListPath isDirectory: &isDir] && !isDir)
{
NSMutableDictionary *cacheDict = [NSDictionary dictionaryWithContentsOfFile: installedAppListPath];
NSDictionary *system = [cacheDict objectForKey: @"System"];
NSMutableArray *installedApp = [NSMutableArray arrayWithArray:[self desktopAppsFromDictionary:system]];
NSDictionary *user = [cacheDict objectForKey: @"User"];
[installedApp addObjectsFromArray:[self desktopAppsFromDictionary:user]];
return installedApp;
}
DLOG(@"can not find installed app plist");
return nil;
}
@end
TA贡献1796条经验 获得超4个赞
在越狱的iPhone上,您只能读取/Applications文件夹。所有已安装的应用程序都去了那里。只需列出目录/Applications使用NSFileManager:
NSArray *appFolderContents = [[NSFileManager defaultManager] directoryContentsAtPath:@"/Applications"];
- 3 回答
- 0 关注
- 1037 浏览
添加回答
举报