iOS之与iTunes文件共享,在程序中获得Document路径

时间:2014-07-03 16:37:49   收藏:0   阅读:201

有时候程序开发需要通过沙盒中的 documents文件夹与用户共享文件,iTunes默认是不支持iTunes file Sharing的,首先设置

info-list的Application supports iTunes file sharing为YES。

这样程序就可以支持文件共享。


然后我将iPad破解后,用91助手往里面存了点东西,作为测试使用,访问Document路径的代码如下:

    NSString *homeDir = NSHomeDirectory();
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    
    NSString *docDir = [paths objectAtIndex:0];

获得路径后,采用NSFileManager获得里面的文件名称存储到NSArray中。

NSArray *fileName = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:docDir error:Nil];

bubuko.com,布布扣

这样就可以获取document下文件的名称了。

iOS之与iTunes文件共享,在程序中获得Document路径,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!