- (NSString *)stringByExpandingTildeInPath

下面是
- (NSString *)stringByExpandingTildeInPath
Description	
Returns a new string made by expanding the initial component of the receiver to its full path value.
Note that this method only works with file paths (not, for example, string representations of URLs).
Returns	
A new string made by expanding the initial component of the receiver, if it begins with “~” or “~user”, to its full path value. Returns a new string matching the receiver if the receiver’s initial component can’t be expanded.
Availability	iOS (2.0 and later)

将路径中的代字符扩展成用户主目录(~)或指定用户的主目录(~user)。


还有其他的一些文件操作

+ (NSString *)pathWithComponents(NSArray *)components
根据components中的元素来构建路径.
- (NSArray *)pathComponents
解析路径,返回构成路径的各个部分.
- (NSString *)lastPathComponent
提取路径中的最后一个组成部分
- (NSString *)pathExtension
从路径中最后一个组成部分中提取扩展名


- (NSString *)stringByAppendingPathComponent(NSString*)path

path添加到现有路径末尾


- (NSString *)stringByAppendingPathExtension(NSString *)ext


将指定的扩展名添加到现有路径的最后一个组成部分上
- (NSString *)stringByDeletingLastPathComponent
删除路径中的最后一个组成部分
- (NSString *)stringByDeletingPathExtension
从文件的最后一部分删除扩展名
- (NSString *)stringByExpandingTildeInPath
将路径中的代字符扩展成用户主目录(~)或指定用户的主目录(~user)
- (NSString *)stringByResolvingSymlinksInPath
尝试解析路径中的符号链接
- (NSString *)stringByStandardizingPath
解析路径中的~,(..)父目录,(.)当前目录和符号链接来标准化路径.

常用的路径工具函数:
NSString * NSUserName (void);
返回当前用户的登录名
NSString * NSFullUserName (void);
返回当前用户的完整用户名
NSString * NSHomeDirectory (void);
返回当前用户主目录的路径
NSString * NSHomeDirectoryForUser ( NSString *userName)
返回用户userName的主目录

NSString * NSTemporaryDirectory (void);
返回可用于创建临时文件的路径目录

NSArray * NSSearchPathForDirectoriesInDomains (
   NSSearchPathDirectory directory,
   NSSearchPathDomainMask domainMask,
   BOOL expandTilde
);
用户查找特定的目录,如: NSDocumentationDirectory, NSUserDirectory等等


复制文件和使用NSProcessInfo类

常用的NSProcessInfo类

+ (NSProcessInfo *)processInfo
返回当前进程信息

- (NSArray *)arguments
以NSString对象数字的形式返回当前进程的参数

- (NSDictionary *)environment
返回变量/值对字典,以描述当前的环境变量(比如PATH等等)

- (int)processIdentifier
返回进程PID

- (NSString *)processName
返回当前正在执行的进程名称

- (NSString *)globallyUniqueString
每次调用该方法时,都会返回不同的单值字符串,可以生成临时文件名

- (NSString *)hostName
返回主机系统名

- (NSUInteger)operatingSystem
返回表示操作系统的数字

- (NSString *)operatingSystemName
返回操作系统的名称

- (NSString *)operatingSystemVersionString
返回操作系统版本



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值