zoukankan      html  css  js  c++  java
  • stringByAppendingPathComponent和stringByAppendingString 的区别

     

    stringByAppendingPathComponent和stringByAppendingString 的区别

     

    stringByAppendingPathComponent

     
    1. NSString * filePath3 = [documentsPath stringByAppendingPathComponent:@"Dictionary"];  

    stringByAppendingString


     
    1. NSString * filePath = [documentsPath stringByAppendingString:@"/hello.txt"];  

    两者比较  

    1、后者需要加"/" ,前者不需要加

    2、前者路径打印出来:/Users/MyMacBook/Library/Developer/CoreSimulator/Devices/C1B4AFE9-2058-40A6-B868-101E166FF961/data/Containers/Data/Application/79CB8A9F-1000-4360-A9EA-801ADF1E0044/Documents/DataBase.sqlite
          后者路径打印出来:/Users/MyMacBook/Library/Developer/CoreSimulator/Devices/C1B4AFE9-2058-40A6-B868-101E166FF961/data/Containers/Data/Application/79CB8A9F-1000-4360-A9EA-801ADF1E0044/Documents

    stringByAppendingPathComponent

    就是将前面的路径格式和后面的普通的字符串格式链接在一起,并且以路径格式返回。

    例如:获取程序家目录NSString *path =NSHomeDirectory();获取后的path是"/root/User/";执行

    path = [path stringByAppendingPathComponent:@"abc.txt"];后path为“/root/User/abc.txt”。




  • 相关阅读:
    全文本的检索
    网卡配置
    linux解压命令
    Session
    swoole安装
    Linux 系统磁盘满处理方法
    php写入和读取文件内容
    PHP读取文件夹的文件列表
    php 公历农历互相转换
    PHP实现RESTful风格的API实例
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5912683.html
Copyright © 2011-2022 走看看