2

私はiOS開発に不慣れです。小さな情報が必要です。すべてのインストールアプリケーションを刑務所で壊れていないデバイスにプログラムで取得する方法。

グーグルで調べましたが、「ジェイルブレイクされていないデバイスでのみ可能」という情報が得られました。

リストを取得する方法を教えてください。私はそのためのコードの下に書いた

    NSFileManager *manager = [NSFileManager defaultManager];
    NSArray *fileList = [manager directoryContentsAtPath:documentsDirectory];
    for (NSString *s in fileList)
    {
       NSLog(s);
    }
4

1 に答える 1

0

注 :アプリケーションは、任意の Apple デバイスでサンドボックス化され、そのサンドボックス化された環境内でのみ情報を使用できます。ジェイルブレイクされていないデバイスでは、アプリケーション環境外で他のアプリケーションの情報を使用することはできません。非ジェイルブレイクされたデバイスに対して以下のコードを使用しようとすると、Apple はアプリを拒否します。このコードは、ジェイルブレイクされたデバイスにのみ使用してください。

サンプルコード:

-(NSMutableArray *)desktopAppsFromDictionary:(NSDictionary *)dictionary
{
    NSMutableArray *desktopApps = [NSMutableArray array];
    for (NSString *appKey in dictionary)    {
        [desktopApps addObject:appKey];
    }
    return desktopApps;
}

-(void)installedApp
{
    static NSString* const installedAppListPath = @"/private/var/mobile/Library/Caches/com.apple.mobile.installation.plist";
    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]];
        NSLog(@"installedApp :: %@",installedApp);
    }
    else
    {
        NSLog(@"Error..");
    }
}

功績はIgor Fedorchukにあります。

AppListというライブラリも 1 つあります。ジェイルブレイクされたデバイスで使用できます。

于 2013-06-27T08:08:24.190 に答える