Retrive app names installed in iPhone

Discussion in 'iOS Programming' started by manga, Jul 18, 2013.

  1. manga, Jul 18, 2013
    Last edited by a moderator: Jul 19, 2013

    manga macrumors newbie

    Oct 3, 2012

    I write bellow code to get apps which are installed in iPhone device.But it works on iOS5.1.1 not works on iOS6.1.3.

    Code is:

        BOOL isDir= NO;
        NSMutableArray *applicationsArray=[[NSMutableArray alloc]init];
        NSDictionary *user, *system;
        static NSString *const cacheFileName = @"";
        NSString *relativeCachePath = [[@"Library" stringByAppendingPathComponent: @"Caches"] stringByAppendingPathComponent: cacheFileName];
        NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent: @"../.."] stringByAppendingPathComponent: relativeCachePath];
        if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir)
            NSDictionary *cacheDict    = [NSDictionary dictionaryWithContentsOfFile: path];
            user = [cacheDict objectForKey: @"User"];
            system=[cacheDict objectForKey:@"System"];
        NSArray *arr1=[[NSArray alloc] initWithArray:[system allKeys]];
        for (int i=0; i<[[system allKeys] count]; i++) {
            [applicationsArray addObject:[[system valueForKey:[arr1 objectAtIndex:i]] valueForKey:@"Path"]];
        NSArray *arr2=[[NSArray alloc] initWithArray:[user allKeys]];
        for (int i=0; i<[[system allKeys] count]; i++) {
            [applicationsArray addObject:[[user valueForKey:[arr2 objectAtIndex:i]] valueForKey:@"Path"]];
        for (int i=0; i<applicationsArray.count; i++)
            NSArray *arr3=[[applicationsArray objectAtIndex:i] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"/"]];
            NSArray *arr4=[[arr3 lastObject] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"."]];
            NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
            [dict setValue:[arr4 objectAtIndex:0] forKey:@"appName"];
            [dict setValue:@"1" forKey:@"State"];
            [self.tableViewArray addObject:dict];

    Please help me out ,how to get app name in iOS6.1.3

    Thanks &Regards,
  2. axeseller macrumors newbie

    Jul 29, 2013

    This code will only work on jailbroken devices. In normal mode, sandboxing prevents you from accessing files outside your app's folder. So maybe, iOS 5 device is jailbroken and iOS 6 is not?

Share This Page