zoukankan      html  css  js  c++  java
  • applicationDocumentsDirectory Path 与 URL

    -(NSURL*)applicationDocumentsDirectory
    {
        return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
    }
    -(NSString*)applicationDocumentsDirectoryPath
    {
        return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    }

    区别如下:

    NSLog(@"%@",storeURL);
    NSLog(@"%@",storePath);
    NSLog(@"%@",[storeURL absoluteString]);

    结果分别为

    file://localhost/Users/apple/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/A2187B83-2937-46AC-9829-D87B4D292E7C/Documents/

    /Users/apple/Library/Application Support/iPhone Simulator/6.0/Applications/A2187B83-2937-46AC-9829-D87B4D292E7C/Documents/

    file://localhost/Users/apple/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/A2187B83-2937-46AC-9829-D87B4D292E7C/Documents/

    因此若需要使用方法

    NSFileManager* fileManager = [NSFileManager defaultManager];
    [fileManager fileExistsAtPath:storePath];

    必须使用applicationDocumentsDirectoryPath,而不能使用 [URL absoluteString];

     

  • 相关阅读:
    你了解RTOS吗?
    [转] git rebase 详解
    MinGW vs MinGW-W64及其它
    【转】Video Rendering with 8-Bit YUV Formats
    Ubuntu假死
    渐进增强和优雅降级的区别
    JavaScript 插件的学习
    菜单的制作
    生活
    小组学习情况
  • 原文地址:https://www.cnblogs.com/wxy325/p/2886575.html
Copyright © 2011-2022 走看看