Jon*_*asG 26 objective-c jailbreak ios
我想获得所有已安装应用程序的列表(NSArray).我的应用程序是一个越狱应用程序,位于/应用程序,所以沙盒是没有问题的.有没有办法获得应用商店应用列表?我已经在其他应用程序中看到了这一点(Activator,SBSettings ......).我不知道如何做到这一点,因为所有的应用程序沙箱都有那么大的代码,所以我不知道如何访问沙箱中的.app文件夹.
Igo*_*gor 14
您可以使用此代码段:
#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
Run Code Online (Sandbox Code Playgroud)
在越狱的iPhone上,您只需阅读该/Applications文件夹即可.所有安装的应用程序都在那 只需列出/Applications使用中的目录NSFileManager:
NSArray *appFolderContents = [[NSFileManager defaultManager] directoryContentsAtPath:@"/Applications"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28628 次 |
| 最近记录: |