//這裏有一個模擬器沙盒路徑(完整路徑)spa
NSString* index=@"/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip";
ip
對路徑截取的9種操做string
NSLog(@"1=%@",[index lastPathComponent]);it
NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);io
NSLog(@"3=%@",[index pathExtension]);ast
NSLog(@"4=%@",[index stringByDeletingPathExtension]);class
NSLog(@"5=%@",[index stringByAbbreviatingWithTildeInPath]);im
NSLog(@"6=%@",[index stringByExpandingTildeInPath]);di
NSLog(@"7=%@",[index stringByStandardizingPath]);vi
NSLog(@"8=%@",[index stringByResolvingSymlinksInPath]);
NSLog(@"9=%@",[[index lastPathComponent] stringByDeletingPathExtension]);
對應結果
1=2013_50.zip
2=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books
3=zip
4=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50
5=~/Documents/DownLoad/books/2013_50.zip
6=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
7=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
8=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
9=2013_50