`

NSSearchPathForDirectoriesInDomains

    博客分类:
  • ios
 
阅读更多

fileManager的基本应用:查看列表

 NSFileManager *fileManager=[NSFileManager defaultManager];
        NSArray *documentPaths=NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory,NSAllDomainsMask , YES);
        for (NSString *str in documentPaths) {
            NSLog(@"documentPaths:%@",str);
        }
        
        NSString *documentDir=[documentPaths objectAtIndex:0] ;
        NSLog(@"documentDir:%@",documentDir);

 结果如下:

2013-06-14 16:30:48.253 helloword[1092:c07] documentPaths:/Users/qing/Library/Application Support/iPhone Simulator/6.1/Applications/A3EEDA4B-0F5E-49E5-91D8-FBCCD388B539/Library/Documentation
2013-06-14 16:30:48.258 helloword[1092:c07] documentPaths:/Library/Documentation
2013-06-14 16:30:48.258 helloword[1092:c07] documentPaths:/Network/Library/Documentation
2013-06-14 16:30:48.259 helloword[1092:c07] documentPaths:/System/Library/Documentation
2013-06-14 16:30:48.260 helloword[1092:c07] documentDir:/Users/qing/Library/Application Support/iPhone Simulator/6.1/Applications/A3EEDA4B-0F5E-49E5-91D8-FBCCD388B539/Library/Documentation

 

NSSearchPathForDirectoriesInDomains:

 

        NSArray *documentPaths=NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory,NSUserDomainMask , YES);
        //documentPaths:/Users/qing/Library/Application Support/iPhone Simulator/6.1/Applications/A3EEDA4B-0F5E-49E5-91D8-FBCCD388B539/Library/Documentation
         documentPaths=NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory,NSAllDomainsMask , YES);
///Users/qing/Library/Application Support/iPhone Simulator/6.1/Applications/A3EEDA4B-0F5E-49E5-91D8-FBCCD388B539/Downloads

 

分享到:
评论

相关推荐

    AppFolder::card_index_dividers:不再使用NSSearchPathForDirectoriesInDomains。 决不

    AppFolder AppFolder是一个轻量级的框架,可让您设计应用程序容器内目录的友好,强类型表示。 所有系统目录(例如“ Caches /”和“ Application Support /”)都已经存在,您只需使用几行代码即可添加您的目录。...

    ios WKWebView 的使用和交互

    // NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); // NSString * path = [paths objectAtIndex:0]; // path = [path stringByAppendingString:[NSString ...

    OC-获取沙盒路径,tmp.library

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // 获取Library目录 paths = ...

    Sandbox 获取沙盒路径

    在iOS和macOS开发中,我们可以使用`FileManager`类和`NSSearchPathForDirectoriesInDomains`函数来获取沙盒路径。 - iOS Swift示例: ```swift let documentsURL = FileManager.default.urls(for: .document...

    iOS沙盒总结

    1、获取程序的Home目录 NSString *path = NSHomeDirectory(); NSLog(@"path:%@",path);... NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *

    OC-获取app缓存大小

    可以使用`NSSearchPathForDirectoriesInDomains`方法,传入`NSCachesDirectory`和`NSUserDomainMask`来获取。 ```objc NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, ...

    IOS应用源码——NSFileManager_DirectoryLocations.rar

    通过`NSSearchPathForDirectoriesInDomains`方法,我们可以指定目录类型(如NSDocumentDirectory)和域(如NSUserDomainMask,代表用户域)来获取相应的路径。 源码示例"NSFileManager_DirectoryLocations"很可能...

    一种实时查看ios模拟器日志方法

    通过NSSearchPathForDirectoriesInDomains获取当前应用的文档目录路径,然后构造出日志文件的完整路径。 实现代码如下: ```objective-c - (void)redirectConsoleLog { #ifdef DEBUG NSArray *paths = ...

    iphone实现文件的读写操作

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // 设置当前工作目录为文档目录 [file...

    详解iOS开发中app的归档以及偏好设置的存储方式

    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSString *path = [docPath stringByAppendingPathComponent:@"person.yangyang"]; ...

    DownLoad 下载练习

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths lastObject]; path = [path stringByAppendingFormat:@"%@\aa", path]; NSLog...

    图片amr语音下载

    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:@"audio.amr"]; // 初始化AVAudioPlayer NSError *error; ...

    iOS沙盒机制

    3. 获取Documents路径:使用NSSearchPathForDirectoriesInDomains()函数,并指定NSDocumentDirectory和NSUserDomainMask,可以定位到Documents目录。然后可以通过字符串操作添加自己的文件路径,比如添加一个名为...

    plist文件读写.zip

    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; filePath = [filePath stringByAppendingPathComponent:@"data.plist"]; NSData *...

    ios沙盒数据存储

    1. 文件路径:使用`NSSearchPathForDirectoriesInDomains`获取沙盒路径,例如`Documents`目录可以通过`NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)`获取。 2. 用户隐私:...

    ios-类自动归解档.zip

    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; NSString *archivePath = [filePath stringByAppendingPathComponent:@"person.archive"];...

    ios指定路径文件大小

    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSLog(@"%@", path); // 指定要检查的文件路径 NSString *filePath = [path ...

    如何在程序中使用多个分数

    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:...

Global site tag (gtag.js) - Google Analytics