获取所有已安装应用程序的列表

我想获取所有已安装应用程序的列表(NSArray)。我的应用程序是一个越狱应用程序,位于/ Applications中,因此Sandbox在那里没有问题。有没有办法获取应用商店应用列表?我已经在其他应用程序(激活器,SBSettings ...)中看到了这一点。我不知道如何执行此操作,因为所有应用程序沙箱均具有大量代码,因此我不知道如何访问沙箱中的.app文件夹。



慕标5832272
浏览 986回答 3
3回答

慕姐4208626

您可以使用以下代码段: #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

慕的地8271018

在越狱的iPhone上,您只能读取/Applications文件夹。所有已安装的应用程序都去了那里。只需列出目录/Applications使用NSFileManager:NSArray *appFolderContents = [[NSFileManager defaultManager] directoryContentsAtPath:@"/Applications"];
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

iOS