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

    Joined:
    Oct 3, 2012
    #1
    Hi,

    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:

    Code:
        BOOL isDir= NO;
        NSMutableArray *applicationsArray=[[NSMutableArray alloc]init];
        
        NSDictionary *user, *system;
        static NSString *const cacheFileName = @"com.apple.mobile.installation.plist";
        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];
            dict=nil;
            arr1=nil;
            arr2=nil;
        }


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



    Thanks &Regards,
    Manga
     
  2. axeseller macrumors newbie

    Joined:
    Jul 29, 2013
    #2
    Jailbroken?

    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