iOS获取文件路径详解手机开发

#import "NSString+WJ.h" 
  
@implementation NSString (WJ) 
  
- (instancetype)cacheDir 
{ 
    //1.获取Caches目录 
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; 
      
    //2.生成绝对路径 
      
    return [path stringByAppendingPathComponent:[self lastPathComponent]]; 
  
} 
  
-(instancetype)docDir 
{ 
      
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) lastObject]; 
      
    return [path stringByAppendingPathComponent:[self lastPathComponent]]; 
} 
  
  
- (instancetype)tmpDir 
{ 
    NSString *path = NSTemporaryDirectory(); 
      
    return [path stringByAppendingPathComponent:[self lastPathComponent]]; 
  
} 
  
@end

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/3351.html

(0)
上一篇 2021年7月16日 14:29
下一篇 2021年7月16日 14:29

相关推荐

发表回复

登录后才能评论