- stringByDeletingLastPathComponent
_rootPath = [@"/var/mobile/Containers/Data/Application/xxxxx" stringByDeletingLastPathComponent];
NSLog(@"%@",_rootPath);
打印结果:/var/mobile/Containers/Data/Application
_rootPath = [@"/var/mobile/Containers/Data/Application/xxxxx" lastPathComponent];
NSLog(@"%@",_rootPath);
打印结果:xxxxx
- stringByExpandingTildeInPath
_rootPath = [@"~" stringByExpandingTildeInPath];
NSLog(@"%@",_rootPath);
打印结果:/var/mobile/Containers/Data/Application/D602EC89-5359-4DF4-AD6F-3AB4496B15CB
_rootPath = [@"~/text.txt" stringByExpandingTildeInPath];
NSLog(@"%@",_rootPath);
打印结果: /var/mobile/Containers/Data/Application/F2D32886-1AEA-49B3-8890-DB534ABE390D/text.txt
- stringByAbbreviatingWithTildeInPath
_rootPath = [@"~/text.txt" stringByExpandingTildeInPath];
_rootPath = [_rootPath stringByAbbreviatingWithTildeInPath];
NSLog(@"%@",_rootPath);
打印结果:~/text.txt
- (nullable NSString *)stringByAppendingPathExtension:(NSString *)str
_rootPath = [@"test" stringByAppendingPathExtension:@"txt"];
NSLog(@"%@",_rootPath);
打印结果:test.txt
_rootPath = [@"test.txt" pathExtension];
NSLog(@"%@",_rootPath);
打印结果:txt
- (NSString *)stringByAppendingPathComponent:(NSString *)str
_rootPath = [@"test" stringByAppendingPathComponent:@"test2"];
NSLog(@"%@",_rootPath);
打印结果:test/test2