zoukankan      html  css  js  c++  java
  • IOS 文件名获取简洁方式

    //这里有一个模拟器沙盒路径(完整路径)

    NSString* index=@"/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip";

     

    对路径截取的9种操作

        NSLog(@"1=%@",[index lastPathComponent]);

        NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);

        NSLog(@"3=%@",[index pathExtension]);

        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]);

     

     

    对应结果

     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

  • 相关阅读:
    用fiddler测试ip轮询
    ubuntu下安装fiddler
    Andriod相机开发关于startPreview Failed的错误的特别记录(重要)
    我的Cocos2dx开发模式
    Android WebView导入HTML使Js生效的方法
    Lua快捷键
    String,StringBuilder,StringBuffer的对比测试
    重构视角(摘抄)
    String属于“假引用类型”,代码为证(一个String引发的血案...)
    static class
  • 原文地址:https://www.cnblogs.com/cwy173/p/9285480.html
Copyright © 2011-2022 走看看