NSString* index=@"/Users/1.zip";
对路径进行截取的9种操作
NSLog(@"1=%@",[index lastPathComponent]);
对应结果1=1.zip
NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);
对应结果 :去掉文件名2= /Users/
NSLog(@"3=%@",[index pathExtension]);
对应结果 :得到文件名后缀: 3=zip
NSLog(@"4=%@",[index stringByDeletingPathExtension]);
对应结果 :除去文件的后缀 4=/Users/1
NSLog(@"5=%@",[[index lastPathComponent] stringByDeletingPathExtension]);对应结果 :取文件名,不带后缀的: 5= 1
新闻热点
疑难解答