//通过数组创建路径
NSArray *arr = @[@"aaa", @"bbb", @" ", @"ccc"];
NSString *path = [NSString pathWithComponents:arr];
//将路径分解成数组
path = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"plist"];
NSArray *array = path.pathComponents;
//判断是否是绝对路径
BOOL flag = path.isAbsolutePath;
//获取路径的最后一个组成部分
NSLog(@"%@", path.lastPathComponent);
//去除路径的最后一个组成部分
NSLog(@"%@", path.stringByDeletingLastPathComponent);
//拼接路径
NSLog(@"%@", [path stringByAppendingPathComponent:@"ffff.xxx"]);
//获取路径扩展名
NSLog(@"%@", path.pathExtension);
//去除路径的扩展名
NSLog(@"%@", path.stringByDeletingPathExtension);
//添加扩展名
NSLog(@"%@", [path stringByAppendingPathExtension:@".vvvv"]);
//将主路径替换成~
NSString *document = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
NSString *tildePath = [document stringByAbbreviatingWithTildeInPath];
NSLog(@"%@", tildePath);
//将~替换成主路径
NSLog(@"%@", tildePath.stringByExpandingTildeInPath);
NSLog(@"%@", path.stringByStandardizingPath);
//还原路径中的符号链接,例如"~"、".."符号等
NSLog(@"%@", path.stringByResolvingSymlinksInPath);
//对路径字符串分别添加字典中的每个路径,形成数组
NSArray *array = [path stringsByAppendingPaths:@[@"xiaobai", @"xiaohei"]];
NSLog(@"%@", array);
//将字符串转成文件系统路径,以utf-8格式编码
path.fileSystemRepresentation;
//筛选数组中指定扩展名的路径
NSArray *arr = @[@"/var/mobile/Containers/Data/Application/583B3A9B-FD29-4517-9EF8-31A40E47D6FC/Documents/1.txt", @"/var/mobile/Containers/Data/Application/583B3A9B-FD29-4517-9EF8-31A40E47D6FC/Documents/2.doc",@"/var/mobile/Containers/Data/Application/583B3A9B-FD29-4517-9EF8-31A40E47D6FC/Documents/3.txt"];
NSArray *temp = [arr pathsMatchingExtensions:@[@"txt", @"plist"]];
//completePathIntoString,不清楚是干嘛的
NSString *path = @"/var/mobile/Containers/Data/Application/583B3A9B-FD29-4517-9EF8-31A40E47D6FC/Documents/1.txt";
NSString *str = @"";
NSArray *arrtemp = [NSArray array];
[path completePathIntoString:&str caseSensitive:NO matchesIntoArray:&arrtemp filterTypes:@[@"txt"]];
NSLog(@"%@", [NSString stringWithUTF8String:path.fileSystemRepresentation]);