亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

獲取所有已安裝應用程序的列表

獲取所有已安裝應用程序的列表

iOS
慕標5832272 2019-11-12 10:34:12
我想獲取所有已安裝應用程序的列表(NSArray)。我的應用程序是一個越獄應用程序,位于/ Applications中,因此Sandbox在那里沒有問題。有沒有辦法獲取應用商店應用列表?我已經在其他應用程序(激活器,SBSettings ...)中看到了這一點。我不知道如何執行此操作,因為所有應用程序沙箱均具有大量代碼,因此我不知道如何訪問沙箱中的.app文件夾。
查看完整描述

3 回答

?
慕姐4208626

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


查看完整回答
反對 回復 2019-11-12
?
慕的地8271018

TA貢獻1796條經驗 獲得超4個贊

在越獄的iPhone上,您只能讀取/Applications文件夾。所有已安裝的應用程序都去了那里。只需列出目錄/Applications使用NSFileManager:


NSArray *appFolderContents = [[NSFileManager defaultManager] directoryContentsAtPath:@"/Applications"];


查看完整回答
反對 回復 2019-11-12
  • 3 回答
  • 0 關注
  • 1073 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號