iOS开发人员能够查看文件系统吗?

巫妖王*_*巫妖王 11 filesystems iphone objective-c ios

我想知道开发人员是否有某种方法可以在iFile这样的iOS设备上查看文件系统但是没有越狱设备?需要它用于devlopement目的.

编辑感谢您的回答!我知道app文件夹里面有一个地方,可以读写.但我一直在寻找一种无需编码即可快速查看数据的方法,例如iFile.所以我可以检查我的写功能是否成功.

小智 13

虽然iDevice上的文件系统是沙箱,但iPhone模拟器中的文件系统却没有.您可以使用模拟器运行您的应用程序并通过以下方式检查内容:

~/Library/Application Support/iPhone Simulator/5.0/Applications
Run Code Online (Sandbox Code Playgroud)

它应该适合您的需求.


tho*_*mas 9

对于设备:使用桌面应用程序iPhone-Explorer它通过USB读取文件系统(它可以读取和写入整个用户指定的区域(应用程序,音乐,照片,视频,笔记等),但不能读取整个系统,除非你越狱并安装afc2add)

对于iPhoneSimulator(像Liz提到的那样): ~/Library/Application Support/iPhone Simulator/5.0/Applications


Sri*_*aju 6

可以在iOS设备中查看文件,但只能查看App的沙箱中的文件.每个应用程序都得到了Documents,Cachetemp文件夹.我认为当您连接设备时,前两个会自动备份iTunes,后者不会备份.

示例,获取缓存目录路径 -

- (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;
}
Run Code Online (Sandbox Code Playgroud)

要查看caches目录中的所有文件-

- (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<count; i++)
    {
        [filePaths addObject:[dirContent objectAtIndex:i]];
    }
    return filePaths;
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢你的回答!我知道app文件夹里面有一个地方,可以读写.但我一直在寻找一种无需编码即可快速查看数据的方法,例如iFile.所以我可以检查我的写功能是否成功. (2认同)