(2016.6.14 这篇文章还是比较清晰路径详解)
对于取文件的路径,总是容易忘记,再次梳理下还是有必要的。
一般的获取程序文件路径的自定义方法:
-(NSString*)documentsDirectory{
NSArray*paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString*documentsDirectory = [pathsfirstObject];
returndocumentsDirectory;
}
取一下各个路径
NSArray*pathArr =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSLog(@"pathArr = %@",pathArr);
pathArr =NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);
NSLog(@"pathArr = %@",pathArr);
pathArr =NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);
NSLog(@"pathArr = %@",pathArr);
NSLog(@"%@",NSHomeDirectory());
NSLog(@"%@",NSTemporaryDirectory());