Is iOS developer able to view file system?

后端 未结 9 1059
面向向阳花
面向向阳花 2020-12-28 10:59

I wonder if developer has some sort of ways to be able to view file system on iOS device like iFile but without jailbreak the device? Need it for devlopement purpose.

<
9条回答
  •  臣服心动
    2020-12-28 11:30

    One can view files in an iOS device but only in that your App's sandbox. Every App has got a Documents, Cache and temp folders. I think the first two are automatically backed up by iTunes when you connect your device, the latter is not backed up.

    Example, to get Cache directory path -

    - (NSString *)getCacheDirPath
    {
        NSString *path = nil;
        NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
        if([myPathList count])
        {
            NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
            path = [[myPathList objectAtIndex:0] stringByAppendingPathComponent:bundleName];
        }
        return path;
    }
    

    To see all files in caches directory -

    - (NSMutableArray *)showFiles
    {
        NSError *err        = nil;
        NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
        NSString *myPath    = [myPathList  objectAtIndex:0];
        NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myPath error:&err];
        if(err) NSLog(@"showFiles() - ERROR: %@",[err localizedDescription]);
        NSMutableArray *filePaths  = nil;
    
        int count = (int)[dirContent count];
        for(int i=0; i

提交回复
热议问题