完整路径
NSString* index=@"/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents/1543976290.wav";
对路径截取的9种操作
NSLog(@"%@",[index lastPathComponent]);
输出:1543976290.wav
NSLog(@"%@",[index stringByDeletingLastPathComponent]);
输出:/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents
NSLog(@"%@",[index pathExtension]);
输出:wav
NSLog(@"%@",[index stringByDeletingPathExtension]);
输出:/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents/1543976290
NSLog(@"%@",[index stringByAbbreviatingWithTildeInPath]);
输出:~/Documents/1543976290.wav
NSLog(@"%@",[index stringByExpandingTildeInPath]);
输出:/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents/1543976290.wav
NSLog(@"%@",[index stringByStandardizingPath]);
输出:/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents/1543976290.wav
NSLog(@"%@",[index stringByResolvingSymlinksInPath]);
输出:/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents/1543976290.wav
NSLog(@"%@",[[index lastPathComponent] stringByDeletingPathExtension]);
输出:1543976290
网友评论