spdocumentlibrary 存储的文件存在物理路径吗

2026年09月23日 21:29
有1个网友回答
网友(1):

  1、模拟器沙盒目录
文件都用户名文件夹隐藏文件夹文叫资源库目录其实Library

应用沙箱(sandbox)文件读写权限受限制能几目录读写文件:
Documents:应用用户数据放iTunes备份恢复候包括目录
tmp:存放临文件iTunes备份恢复目录目录文件能应用退删除
Library/Caches:存放缓存文件iTunes备份目录目录文件应用退删除

iTunes与iPhone同步备份所DocumentsLibrary文件
iPhone重启丢弃所tmp文件

查看:
1、设置显示隐藏文件Finder直接打设置查看隐藏文件:打终端输入命名
(1)显示Mac隐藏文件命令:defaults write com.apple.finder AppleShowAllFiles -bool true
(2)隐藏Mac隐藏文件命令:defaults write com.apple.finder AppleShowAllFiles -bool false
(3)输完单击Enter键退终端重新启Finder 重启Finder:鼠标单击窗口左角苹标志-->强制退-->Finder-->
现能看资源库文件夹
打资源库找/Application Support/iPhone Simulator/文件夹面模拟器各程序沙盒目录
2、种更便Finder点->前往->前往文件夹输入/Users/username/Library/Application Support/iPhone Simulator/ 前往
username写用户名
  
  代码查看目录:

  NSString *path = NSHomeDirectory();//主目录
NSLog(@"NSHomeDirectory:%@",path);
NSString *userName = NSUserName();//与面相同
NSString *rootPath = NSHomeDirectoryForUser(userName);
NSLog(@"NSHomeDirectoryForUser:%@",rootPath);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory=[paths objectAtIndex:0];//Documents目录
NSLog(@"NSDocumentDirectory:%@",documentsDirectory);

  结:
  2013-09-03 20:31:27.210 ios啥[8383:c07] NSHomeDirectory:/Users/wmm/Library/Application Support/iPhone Simulator/6.1/Applications/D803DBD2-9CB2-4D18-9152-6E9398EFF5DB2013-09-03 20:31:27.210 ios啥[8383:c07] NSHomeDirectoryForUser:/Users/wmm/Library/Application Support/iPhone Simulator/6.1/Applications/D803DBD2-9CB2-4D18-9152-6E9398EFF5DB2013-09-03 20:31:27.211 ios啥[8383:c07] NSDocumentDirectory:/Users/wmm/Library/Application Support/iPhone Simulator/6.1/Applications/D803DBD2-9CB2-4D18-9152-6E9398EFF5DB/Documents 自定义类返各目录路径:

  #import Foundation.h>

@interface ICSandboxHelper : NSObject

+ (NSString *)homePath; // 程序主目录见目录(3):Documents、Library、tmp
+ (NSString *)appPath; // 程序目录能存任何东西
+ (NSString *)docPath; // 文档目录需要ITUNES同步备份数据存存放用户数据
+ (NSString *)libPrefPath; // 配置目录配置文件存
+ (NSString *)libCachePath; // 缓存目录系统永远删除文件ITUNES删除
+ (NSString *)tmpPath; // 临缓存目录APP退系统能删除内容
+ (BOOL)hasLive:(NSString *)path; //判断目录否存存则创建

  #import "ICSandboxHelper.h"

@implementation ICSandboxHelper

+ (NSString *)homePath{
return NSHomeDirectory();
}

+ (NSString *)appPath
{
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, YES);
return [paths objectAtIndex:0];
}

+ (NSString *)docPath
{
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [paths objectAtIndex:0];
}

+ (NSString *)libPrefPath
{
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
return [[paths objectAtIndex:0] stringByAppendingFormat:@"/Preference"];
}

+ (NSString *)libCachePath
{
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
return [[paths objectAtIndex:0] stringByAppendingFormat:@"/Caches"];
}

+ (NSString *)tmpPath
{return [NSHomeDirectory() stringByAppendingFormat:@"/tmp"];
}

+ (BOOL)hasLive:(NSString *)path
{
if ( NO == [[NSFileManager defaultManager] fileExistsAtPath:path] )
{
return [[NSFileManager defaultManager] createDirectoryAtPath:path
withIntermediateDirectories:YES
attributes:nil
error:NULL];
}

return NO;
}
这种提问感觉没有意义
这个可以自己找下资料