NSString *home = NSHomeDirectory();//获取当前应用程序的home目录
NSLog(@"%@",home);
NSString *documents = [home stringByAppendingString:@"/Documents"];//获取Documents目录
NSString *documents1 = [home stringByAppendingPathComponent:@"Documents"];
NSLog(@"%@",documents);
NSLog(@"%@",documents1);
NSString *tmp = NSTemporaryDirectory();//获取tmp目录
NSLog(@"%@",tmp);
NSBundle *mainBundle = [NSBundle mainBundle];//获取主包对象
NSString *path = [mainBundle bundlePath];//获取主包路径
NSString *path1 = [[NSBundle mainBundle] bundlePath];
NSLog(@"%@",path);
NSLog(@"%@",path1);
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];//获取主包中的文件路径
NSLog(@"%@",filePath);
//使用搜索的方式获取一些目录
//1. NSDocumentDirectory
//2. NSLibraryDirectory
//3. NSCachesDirectory
NSArray *arr = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);//搜索路径
NSLog(@"%@",arr);
NSString *userPath = arr[0];
NSLog(@"%@",userPath);
NSArray *arr1 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSLog(@"%@",arr1);
NSLog(@"%@",home);
NSString *documents = [home stringByAppendingString:@"/Documents"];//获取Documents目录
NSString *documents1 = [home stringByAppendingPathComponent:@"Documents"];
NSLog(@"%@",documents);
NSLog(@"%@",documents1);
NSString *tmp = NSTemporaryDirectory();//获取tmp目录
NSLog(@"%@",tmp);
NSBundle *mainBundle = [NSBundle mainBundle];//获取主包对象
NSString *path = [mainBundle bundlePath];//获取主包路径
NSString *path1 = [[NSBundle mainBundle] bundlePath];
NSLog(@"%@",path);
NSLog(@"%@",path1);
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];//获取主包中的文件路径
NSLog(@"%@",filePath);
//使用搜索的方式获取一些目录
//1. NSDocumentDirectory
//2. NSLibraryDirectory
//3. NSCachesDirectory
NSArray *arr = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);//搜索路径
NSLog(@"%@",arr);
NSString *userPath = arr[0];
NSLog(@"%@",userPath);
NSArray *arr1 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSLog(@"%@",arr1);