美文网首页
iOS 从url中获取文件名以及后缀

iOS 从url中获取文件名以及后缀

作者: 奔跑吧小蚂蚁 | 来源:发表于2019-04-30 14:13 被阅读0次

    NSString* index=@"/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip";
    /最后一个“/”之后的部分/
    NSLog(@"1=%@",[index lastPathComponent]);
    /最后一个“/”之前的部分/
    NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);
    /最后一个“/”之前的部分的后缀名称/
    NSLog(@"3=%@",[index pathExtension]);
    /此方法仅仅适用于文件夹路径 不适用于URL 获取主目录/
    NSLog(@"4=%@",[index stringByDeletingPathExtension]);

    NSLog(@"5=%@",[index stringByAbbreviatingWithTildeInPath]);
    
    NSLog(@"6=%@",[index stringByExpandingTildeInPath]);
    
    NSLog(@"7=%@",[index stringByStandardizingPath]);
    
    NSLog(@"8=%@",[index stringByResolvingSymlinksInPath]);
    
    NSLog(@"9=%@",[[index lastPathComponent] stringByDeletingPathExtension]);
    

    https://www.jianshu.com/p/8f049d61e795 NSString 截取详情

    相关文章

      网友评论

          本文标题:iOS 从url中获取文件名以及后缀

          本文链接:https://www.haomeiwen.com/subject/lsfvnqtx.html