Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

manga

macrumors newbie
Original poster
Oct 3, 2012
8
0
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
 
Last edited by a moderator:
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.