IT虾米网

iOS获取文件路径

itxm 2018年06月23日 手机开发 984 0
#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

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

iOS中 用FMDB封装一个SQLite数据库