有两种获取沙盒路径的方法:
//第一种方法
//(1)获取主目录
NSString *homePath = NSHomeDirectory();
//(2)拼接路径
NSString *documentsPath = [homePath stringByAppendingPathComponent:@"Documents"];
NSLog(@"Documents路径:%@\n",documentsPath);
//第二种方法
NSArray *documentArray =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [documentArray objectAtIndex:0];
NSLog(@"Documents路径:%@\n",documentsPath);
NSArray *libraryArray = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryPath = [libraryArray objectAtIndex:0];
NSLog(@"Library路径:%@\n",libraryPath);
NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSLog(@"Library下的Caches路径:%@\n",cachesPath);
NSString *tmpPath = NSTemporaryDirectory();
NSLog(@"tmp路径:%@\n",tmpPath);