iOS 从url中获取文件名以及后缀
示例地址:
NSString* index=@"/var/mobile/Containers/Data/Application/45471D33-E611-499D-AFA1-856880F47549/Documents/1543976290.wav";
C/C++ Code复制内容到剪贴板
- 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